cache/op.h
changeset 31 12d5361e7472
parent 30 33e464fd6773
child 32 1b09dad6757e
equal deleted inserted replaced
30:33e464fd6773 31:12d5361e7472
     1 #ifndef CACHE_OP_H
     1 #ifndef CACHE_OP_H
     2 #define CACHE_OP_H
     2 #define CACHE_OP_H
       
     3 
       
     4 #include <sys/queue.h>
     3 
     5 
     4 enum cache_op_state {
     6 enum cache_op_state {
     5     OP_STATE_INVALID,
     7     OP_STATE_INVALID,
     6     OP_STATE_LOOKUP,
     8     OP_STATE_LOOKUP,
     7 
     9 
     8     OP_STATE_MISS,
    10     OP_STATE_MISS,
     9     OP_STATE_HIT,
    11     OP_STATE_HIT,
       
    12 
       
    13     OP_STATE_WRITE,
    10 };
    14 };
    11 
    15 
    12 struct cache_op {
    16 struct cache_op {
    13     struct cache *cache;
    17     struct cache *cache;
    14 
    18 
    36  * Add the given cache_req to the list of reqs using this op
    40  * Add the given cache_req to the list of reqs using this op
    37  */
    41  */
    38 int cache_op_register (struct cache_op *op, struct cache_req *req);
    42 int cache_op_register (struct cache_op *op, struct cache_req *req);
    39 
    43 
    40 /*
    44 /*
       
    45  * Prepare op for writing data to it, size_hint can be used to preallocate resources
       
    46  */
       
    47 int cache_op_begin_write (struct cache_op *op, size_t size_hint);
       
    48 
       
    49 int cache_op_push (struct cache_op *op, int fd, size_t *size);
       
    50 
       
    51 /*
    41  * Used by the engines to notify that the key lookup completed
    52  * Used by the engines to notify that the key lookup completed
    42  */
    53  */
    43 int cache_op_lookup_done (struct cache_op *op, int found);
    54 int cache_op_lookup_done (struct cache_op *op, int found);
    44 
    55 
       
    56 /*
       
    57  * in OP_STATE_WRITE
       
    58  */
       
    59 int cache_op_write_ready (struct cache_op *op);
       
    60 
       
    61 int cache_op_data_available (struct cache_op *op);
       
    62 int cache_op_write_done (struct cache_op *op);
       
    63 
    45 #endif /* CACHE_OP_H */
    64 #endif /* CACHE_OP_H */