2006-07-29 00:56:54 +00:00
|
|
|
#ifndef ALLOCATION_POLICY_H
|
|
|
|
#define ALLOCATION_POLICY_H
|
|
|
|
|
2008-10-03 02:42:25 +00:00
|
|
|
#include <stasis/common.h>
|
|
|
|
|
2009-08-05 06:35:11 +00:00
|
|
|
struct stasis_allocation_policy_t;
|
|
|
|
typedef struct stasis_allocation_policy_t stasis_allocation_policy_t;
|
2006-07-29 00:56:54 +00:00
|
|
|
|
2009-05-08 06:53:30 +00:00
|
|
|
stasis_allocation_policy_t * stasis_allocation_policy_init();
|
|
|
|
void stasis_allocation_policy_deinit(stasis_allocation_policy_t * ap);
|
2009-08-05 06:35:11 +00:00
|
|
|
void stasis_allocation_policy_register_new_page(stasis_allocation_policy_t * ap, pageid_t page, size_t freespace); //availablePage** newPages);
|
|
|
|
pageid_t stasis_allocation_policy_pick_suitable_page(stasis_allocation_policy_t * ap, int xid, size_t freespace);
|
2009-05-08 06:53:30 +00:00
|
|
|
void stasis_allocation_policy_transaction_completed(stasis_allocation_policy_t * ap, int xid);
|
2009-08-05 06:35:11 +00:00
|
|
|
void stasis_allocation_policy_update_freespace(stasis_allocation_policy_t * ap, pageid_t pageid, size_t freespace);
|
|
|
|
void stasis_allocation_policy_dealloced_from_page(stasis_allocation_policy_t * ap, int xid, pageid_t page);
|
2009-05-08 06:53:30 +00:00
|
|
|
void stasis_allocation_policy_alloced_from_page(stasis_allocation_policy_t * ap, int xid, pageid_t page);
|
2008-10-27 23:30:53 +00:00
|
|
|
/**
|
|
|
|
Check to see if it is safe to allocate from a particular page.
|
|
|
|
|
|
|
|
If concurrent transactions have freed up space on a page, but they
|
|
|
|
eventually abort, then it might not be safe for the current
|
|
|
|
transaction to reuse the storage those transactions freed. This is
|
|
|
|
needed for methods such as TallocFromPage(), which do not consult
|
|
|
|
allocation policy before deciding where to attempt allocation.
|
|
|
|
|
|
|
|
@param ap The allocation policy managing the space in question
|
|
|
|
@param xid The transaction that wants to allocate space from the page
|
|
|
|
@param page The page that will be allocated from.
|
|
|
|
@return true if the allocation would be safe. false if not sure.
|
|
|
|
*/
|
2009-05-08 06:53:30 +00:00
|
|
|
int stasis_allocation_policy_can_xid_alloc_from_page(stasis_allocation_policy_t * ap, int xid, pageid_t page);
|
2006-07-29 00:56:54 +00:00
|
|
|
#endif // ALLOCATION_POLICY_H
|