Big up for Volca ... slowdown the busy icon
[open-ps2-loader.git] / include / ioman.h
blobb03782c6d1a50c5629dd5f4dd082a717bede4a7f
1 #ifndef __IOMAN_H
2 #define __IOMAN_H
4 // Input output manager
5 // asynchronous io handling thread with worker queue
7 #define IO_OK 0
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 */
22 void ioInit(void);
24 /** deinitializes the io worker thread */
25 void ioEnd(void);
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);
59 #ifdef __DEBUG
60 #define PREINIT_LOG(...) printf(__VA_ARGS__)
61 #define LOG(...) ioPrintf(__VA_ARGS__)
62 #else
63 #define PREINIT_LOG(...)
64 #define LOG(...)
65 #endif
67 #endif