4 // Input output manager
5 // asynchronous io handling thread with worker queue
8 #define IO_ERR_UNKNOWN_REQUEST_TYPE -1
9 #define IO_ERR_TOO_MANY_HANDLERS -2
10 #define IO_ERR_DUPLICIT_HANDLER -3
11 #define IO_ERR_INVALID_HANDLER -4
12 #define IO_ERR_IO_BLOCKED -5
14 // handler for parameter-less actions
15 #define IO_CUSTOM_SIMPLEACTION 1
17 typedef void (*io_request_handler_t
)(void* request
);
19 typedef void (*io_simpleaction_t
)(void);
21 /** initializes the io worker thread */
24 /** deinitializes the io worker thread */
27 /** registers a handler for a certain request type */
28 int ioRegisterHandler(int type
, io_request_handler_t handler
);
30 /** schedules a new request into the pending request list
31 * @note The data are not freed! */
32 int ioPutRequest(int type
, void* data
);
34 /** removes all requests of a given type from the queue
35 * @param type the type of the requests to remove
36 * @return the count of the requests removed */
37 int ioRemoveRequests(int type
);
39 /** returns the count of pending requests */
40 int ioGetPendingRequestCount(void);
42 /** returns nonzero if there are any pending io requests */
43 int ioHasPendingRequests(void);
45 /** returns nonzero if the io thread is running */
46 int ioIsRunning(void);
48 /** Helper thread safe printf */
49 int ioPrintf(const char* format
, ...);
51 /** Helper function. Will flush the io operation list
52 (wait for all io ops requested to end) and then
53 issue a blocking flag that will mean no io
54 operation will get in.
55 @param block If nonzero, will issue blocking, otherwise it will unblock
57 int ioBlockOps(int block
);
60 #define PREINIT_LOG(...) printf(__VA_ARGS__)
61 #define LOG(...) ioPrintf(__VA_ARGS__)
63 #define PREINIT_LOG(...)