2 #ifndef _MONO_UTILS_W32HANDLE_H_
3 #define _MONO_UTILS_W32HANDLE_H_
8 #ifndef INVALID_HANDLE_VALUE
9 #define INVALID_HANDLE_VALUE (gpointer)-1
12 #define MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS 64
15 MONO_W32HANDLE_UNUSED = 0,
17 MONO_W32HANDLE_CONSOLE,
18 MONO_W32HANDLE_THREAD,
22 MONO_W32HANDLE_SOCKET,
24 MONO_W32HANDLE_PROCESS,
26 MONO_W32HANDLE_NAMEDMUTEX,
27 MONO_W32HANDLE_NAMEDSEM,
28 MONO_W32HANDLE_NAMEDEVENT,
34 void (*close)(gpointer handle, gpointer data);
36 /* SignalObjectAndWait */
37 void (*signal)(gpointer signal);
39 /* Called by WaitForSingleObject and WaitForMultipleObjects,
40 * with the handle locked (shared handles aren't locked.)
41 * Returns TRUE if ownership was established, false otherwise.
42 * If TRUE, *statuscode contains a status code such as
43 * WAIT_OBJECT_0 or WAIT_ABANDONED_0.
45 gboolean (*own_handle)(gpointer handle, guint32 *statuscode);
47 /* Called by WaitForSingleObject and WaitForMultipleObjects, if the
48 * handle in question is "ownable" (ie mutexes), to see if the current
49 * thread already owns this handle
51 gboolean (*is_owned)(gpointer handle);
53 /* Called by WaitForSingleObject and WaitForMultipleObjects,
54 * if the handle in question needs a special wait function
55 * instead of using the normal handle signal mechanism.
56 * Returns the WaitForSingleObject return code.
58 guint32 (*special_wait)(gpointer handle, guint32 timeout, gboolean *alerted);
60 /* Called by WaitForSingleObject and WaitForMultipleObjects,
61 * if the handle in question needs some preprocessing before the
64 void (*prewait)(gpointer handle);
66 /* Called when dumping the handles */
67 void (*details)(gpointer data);
69 /* Called to get the name of the handle type */
70 const gchar* (*typename) (void);
72 /* Called to get the size of the handle type */
73 gsize (*typesize) (void);
77 MONO_W32HANDLE_CAP_WAIT = 0x01,
78 MONO_W32HANDLE_CAP_SIGNAL = 0x02,
79 MONO_W32HANDLE_CAP_OWN = 0x04,
80 MONO_W32HANDLE_CAP_SPECIAL_WAIT = 0x08,
81 } MonoW32HandleCapability;
83 extern guint32 mono_w32handle_fd_reserve;
86 mono_w32handle_init (void);
89 mono_w32handle_cleanup (void);
92 mono_w32handle_register_ops (MonoW32HandleType type, MonoW32HandleOps *ops);
95 mono_w32handle_new (MonoW32HandleType type, gpointer handle_specific);
98 mono_w32handle_new_fd (MonoW32HandleType type, int fd, gpointer handle_specific);
101 mono_w32handle_get_type (gpointer handle);
104 mono_w32handle_lookup (gpointer handle, MonoW32HandleType type, gpointer *handle_specific);
107 mono_w32handle_search (MonoW32HandleType type, gboolean (*check)(gpointer, gpointer), gpointer user_data, gpointer *handle_specific, gboolean search_shared);
110 mono_w32handle_foreach (gboolean (*on_each)(gpointer handle, gpointer data, gpointer user_data), gpointer user_data);
113 mono_w32handle_dump (void);
116 mono_w32handle_ref (gpointer handle);
119 mono_w32handle_unref (gpointer handle);
122 mono_w32handle_register_capabilities (MonoW32HandleType type, MonoW32HandleCapability caps);
125 mono_w32handle_test_capabilities (gpointer handle, MonoW32HandleCapability caps);
128 mono_w32handle_ops_close (gpointer handle, gpointer data);
131 mono_w32handle_ops_signal (gpointer handle);
134 mono_w32handle_ops_own (gpointer handle, guint32 *statuscode);
137 mono_w32handle_ops_isowned (gpointer handle);
140 mono_w32handle_ops_specialwait (gpointer handle, guint32 timeout, gboolean *alerted);
143 mono_w32handle_ops_prewait (gpointer handle);
146 mono_w32handle_ops_details (MonoW32HandleType type, gpointer data);
149 mono_w32handle_ops_typename (MonoW32HandleType type);
152 mono_w32handle_ops_typesize (MonoW32HandleType type);
155 mono_w32handle_set_signal_state (gpointer handle, gboolean state, gboolean broadcast);
158 mono_w32handle_issignalled (gpointer handle);
161 mono_w32handle_lock_handle (gpointer handle);
164 mono_w32handle_trylock_handle (gpointer handle);
167 mono_w32handle_unlock_handle (gpointer handle);
170 MONO_W32HANDLE_WAIT_RET_SUCCESS_0 = 0,
171 MONO_W32HANDLE_WAIT_RET_ABANDONED_0 = MONO_W32HANDLE_WAIT_RET_SUCCESS_0 + MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS,
172 MONO_W32HANDLE_WAIT_RET_ALERTED = -1,
173 MONO_W32HANDLE_WAIT_RET_TIMEOUT = -2,
174 MONO_W32HANDLE_WAIT_RET_FAILED = -3,
175 } MonoW32HandleWaitRet;
178 mono_w32handle_wait_one (gpointer handle, guint32 timeout, gboolean alertable);
181 mono_w32handle_wait_multiple (gpointer *handles, gsize nhandles, gboolean waitall, guint32 timeout, gboolean alertable);
184 mono_w32handle_signal_and_wait (gpointer signal_handle, gpointer wait_handle, guint32 timeout, gboolean alertable);
186 #endif /* _MONO_UTILS_W32HANDLE_H_ */