2 * UCW Library -- Asynchronous I/O
4 * (c) 2006 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
13 #include "lib/workqueue.h"
14 #include "lib/clists.h"
16 /* FIXME: Comment, especially on request ordering */
19 uns buffer_size; // How large buffers do we use [user-settable]
20 uns max_writebacks; // Maximum number of writeback requests active [user-settable]
21 uns allocated_requests;
22 uns running_requests; // Total number of running requests
23 uns running_writebacks; // How many of them are writebacks
24 clist idle_list; // Recycled requests waiting for get
25 clist done_list; // Finished requests
26 struct work_queue queue;
27 uns use_count; // For use by the caller
34 ASIO_WRITE_BACK, // Background write with no success notification
38 struct work work; // asio_requests are internally just work nodes
39 struct asio_queue *queue;
47 void *user_data; // For use by the caller
50 void asio_init_queue(struct asio_queue *q); // Initialize a new queue
51 void asio_cleanup_queue(struct asio_queue *q);
52 struct asio_request *asio_get(struct asio_queue *q); // Get an empty request
53 void asio_submit(struct asio_request *r); // Submit the request (can block if too many writebacks)
54 struct asio_request *asio_wait(struct asio_queue *q); // Wait for the first finished request, NULL if no more
55 void asio_put(struct asio_request *r); // Return a finished request for recycling
56 void asio_sync(struct asio_queue *q); // Wait until all requests are finished
58 #endif /* !_UCW_ASIO_H */