X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Fbluesky-private.h;h=7f5e64615ae1e986331970332f3d03846253261c;hb=c513d64c6a1f7c2ff2bad97db69e2f40ef642167;hp=a450085e7fdc7826e5b93d1e95b98eca96f98ff8;hpb=b7e08dcf6552eb8977ccef56f00e775da8133cf8;p=bluesky.git diff --git a/bluesky/bluesky-private.h b/bluesky/bluesky-private.h index a450085..7f5e646 100644 --- a/bluesky/bluesky-private.h +++ b/bluesky/bluesky-private.h @@ -29,6 +29,62 @@ BlueSkyFS *bluesky_deserialize_superblock(const gchar *buf); void bluesky_serialize_inode(GString *out, BlueSkyInode *inode); BlueSkyInode *bluesky_deserialize_inode(BlueSkyFS *fs, const gchar *buf); +/* Storage layer. Requests can be performed asynchronously, so these objects + * help keep track of operations in progress. */ +typedef enum { + STORE_OP_NONE, + STORE_OP_GET, + STORE_OP_PUT, + STORE_OP_DELETE, +} BlueSkyStoreOp; + +typedef enum { + ASYNC_NEW, // Operation not yet submitted to storage layer + ASYNC_PENDING, // Submitted to storage layer + ASYNC_RUNNING, // Operation is in progress + ASYNC_COMPLETE, // Operation finished, results available +} BlueSkyAsyncStatus; + +typedef struct { + BlueSkyStore *store; + + GMutex *lock; + GCond *completion_cond; /* Used to wait for operation to complete. */ + + BlueSkyAsyncStatus status; + + BlueSkyStoreOp op; + gchar *key; /* Key to read/write */ + BlueSkyRCStr *data; /* Data read/to write */ + + int result; /* Result code; 0 for success. */ + + gpointer store_private; /* For use by the storage implementation */ +} BlueSkyStoreAsync; + +/* The abstraction layer for storage, allowing multiple implementations. */ +typedef struct { + /* Create a new store instance and return a handle to it. */ + gpointer (*create)(); + + /* Clean up any resources used by this store. */ + void (*destroy)(gpointer store); + + /* Submit an operation (get/put/delete) to the storage layer to be + * performed asynchronously. */ + void (*submit)(gpointer store, BlueSkyStoreAsync *async); + + /* Clean up any implementation-private data in a BlueSkyStoreAsync. */ + void (*cleanup)(gpointer store, BlueSkyStoreAsync *async); +} BlueSkyStoreImplementation; + +void bluesky_store_register(const BlueSkyStoreImplementation *impl, + const gchar *name); + +BlueSkyStoreAsync *bluesky_store_async_new(BlueSkyStore *store); +void bluesky_store_async_wait(BlueSkyStoreAsync *async); +void bluesky_store_async_mark_complete(BlueSkyStoreAsync *async); + #ifdef __cplusplus } #endif