X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Fbluesky-private.h;h=d5e5d4fb74bd7967d00d034ce8d304ce06ce822b;hb=d5e2f1643a99e57607e86173d832dbfa4f8b51c2;hp=7f5e64615ae1e986331970332f3d03846253261c;hpb=c513d64c6a1f7c2ff2bad97db69e2f40ef642167;p=bluesky.git diff --git a/bluesky/bluesky-private.h b/bluesky/bluesky-private.h index 7f5e646..d5e5d4f 100644 --- a/bluesky/bluesky-private.h +++ b/bluesky/bluesky-private.h @@ -36,6 +36,7 @@ typedef enum { STORE_OP_GET, STORE_OP_PUT, STORE_OP_DELETE, + STORE_OP_BARRIER, // Waits for other selected operations to complete } BlueSkyStoreOp; typedef enum { @@ -45,12 +46,15 @@ typedef enum { ASYNC_COMPLETE, // Operation finished, results available } BlueSkyAsyncStatus; +struct BlueSkyNotifierList; typedef struct { BlueSkyStore *store; GMutex *lock; GCond *completion_cond; /* Used to wait for operation to complete. */ + gint refcount; /* Reference count for destruction. */ + BlueSkyAsyncStatus status; BlueSkyStoreOp op; @@ -58,10 +62,22 @@ typedef struct { BlueSkyRCStr *data; /* Data read/to write */ int result; /* Result code; 0 for success. */ + struct BlueSkyNotifierList *notifiers; gpointer store_private; /* For use by the storage implementation */ } BlueSkyStoreAsync; +/* Support for notification lists. These are lists of one-shot functions which + * can be called when certain events--primarily, competed storage + * events--occur. Multiple notifiers can be added, but no particular order is + * guaranteed for the notification functions to be called. */ +struct BlueSkyNotifierList { + struct BlueSkyNotifierList *next; + GFunc func; + BlueSkyStoreAsync *async; + gpointer user_data; // Passed to the function when called +}; + /* The abstraction layer for storage, allowing multiple implementations. */ typedef struct { /* Create a new store instance and return a handle to it. */ @@ -82,8 +98,23 @@ void bluesky_store_register(const BlueSkyStoreImplementation *impl, const gchar *name); BlueSkyStoreAsync *bluesky_store_async_new(BlueSkyStore *store); +void bluesky_store_async_ref(BlueSkyStoreAsync *async); +void bluesky_store_async_unref(BlueSkyStoreAsync *async); void bluesky_store_async_wait(BlueSkyStoreAsync *async); +void bluesky_store_async_add_notifier(BlueSkyStoreAsync *async, + GFunc func, gpointer user_data); void bluesky_store_async_mark_complete(BlueSkyStoreAsync *async); +void bluesky_store_async_submit(BlueSkyStoreAsync *async); +void bluesky_store_sync(BlueSkyStore *store); + +void bluesky_store_add_barrier(BlueSkyStoreAsync *barrier, + BlueSkyStoreAsync *async); + +void bluesky_inode_start_sync(BlueSkyInode *inode, BlueSkyStoreAsync *barrier); + +void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block, + BlueSkyStoreAsync *barrier); +void bluesky_file_flush(BlueSkyInode *inode, BlueSkyStoreAsync *barrier); #ifdef __cplusplus }