2 #ifndef _MONO_UTILS_W32HANDLE_H_
3 #define _MONO_UTILS_W32HANDLE_H_
7 #if !defined(HOST_WIN32)
11 #define INVALID_HANDLE_VALUE (gpointer)-1
14 MONO_W32HANDLE_UNUSED = 0,
16 MONO_W32HANDLE_CONSOLE,
17 MONO_W32HANDLE_THREAD,
21 MONO_W32HANDLE_SOCKET,
23 MONO_W32HANDLE_PROCESS,
25 MONO_W32HANDLE_NAMEDMUTEX,
26 MONO_W32HANDLE_NAMEDSEM,
27 MONO_W32HANDLE_NAMEDEVENT,
33 void (*close)(gpointer handle, gpointer data);
35 /* SignalObjectAndWait */
36 void (*signal)(gpointer signal);
38 /* Called by WaitForSingleObject and WaitForMultipleObjects,
39 * with the handle locked (shared handles aren't locked.)
40 * Returns TRUE if ownership was established, false otherwise.
42 gboolean (*own_handle)(gpointer handle);
44 /* Called by WaitForSingleObject and WaitForMultipleObjects, if the
45 * handle in question is "ownable" (ie mutexes), to see if the current
46 * thread already owns this handle
48 gboolean (*is_owned)(gpointer handle);
50 /* Called by WaitForSingleObject and WaitForMultipleObjects,
51 * if the handle in question needs a special wait function
52 * instead of using the normal handle signal mechanism.
53 * Returns the WaitForSingleObject return code.
55 guint32 (*special_wait)(gpointer handle, guint32 timeout, gboolean alertable);
57 /* Called by WaitForSingleObject and WaitForMultipleObjects,
58 * if the handle in question needs some preprocessing before the
61 void (*prewait)(gpointer handle);
63 /* Called when dumping the handles */
64 void (*details)(gpointer data);
66 /* Called to get the name of the handle type */
67 const gchar* (*typename) (void);
69 /* Called to get the size of the handle type */
70 gsize (*typesize) (void);
74 MONO_W32HANDLE_CAP_WAIT = 0x01,
75 MONO_W32HANDLE_CAP_SIGNAL = 0x02,
76 MONO_W32HANDLE_CAP_OWN = 0x04,
77 MONO_W32HANDLE_CAP_SPECIAL_WAIT = 0x08,
78 } MonoW32HandleCapability;
80 extern guint32 mono_w32handle_fd_reserve;
83 mono_w32handle_init (void);
86 mono_w32handle_cleanup (void);
89 mono_w32handle_register_ops (MonoW32HandleType type, MonoW32HandleOps *ops);
92 mono_w32handle_new (MonoW32HandleType type, gpointer handle_specific);
95 mono_w32handle_new_fd (MonoW32HandleType type, int fd, gpointer handle_specific);
98 mono_w32handle_get_type (gpointer handle);
101 mono_w32handle_lookup (gpointer handle, MonoW32HandleType type, gpointer *handle_specific);
104 mono_w32handle_search (MonoW32HandleType type, gboolean (*check)(gpointer, gpointer), gpointer user_data, gpointer *handle_specific, gboolean search_shared);
107 mono_w32handle_foreach (gboolean (*on_each)(gpointer handle, gpointer data, gpointer user_data), gpointer user_data);
110 mono_w32handle_dump (void);
113 mono_w32handle_ref (gpointer handle);
116 mono_w32handle_unref (gpointer handle);
119 mono_w32handle_register_capabilities (MonoW32HandleType type, MonoW32HandleCapability caps);
122 mono_w32handle_test_capabilities (gpointer handle, MonoW32HandleCapability caps);
125 mono_w32handle_ops_close (gpointer handle, gpointer data);
128 mono_w32handle_ops_signal (gpointer handle);
131 mono_w32handle_ops_own (gpointer handle);
134 mono_w32handle_ops_isowned (gpointer handle);
137 mono_w32handle_ops_specialwait (gpointer handle, guint32 timeout, gboolean alertable);
140 mono_w32handle_ops_prewait (gpointer handle);
143 mono_w32handle_ops_details (MonoW32HandleType type, gpointer data);
146 mono_w32handle_ops_typename (MonoW32HandleType type);
149 mono_w32handle_ops_typesize (MonoW32HandleType type);
152 mono_w32handle_count_signalled_handles (guint32 numhandles, gpointer *handles, gboolean waitall, guint32 *retcount, guint32 *lowest);
155 mono_w32handle_unlock_handles (guint32 numhandles, gpointer *handles);
158 mono_w32handle_timedwait_signal_handle (gpointer handle, guint32 timeout, gboolean poll, gboolean *alerted);
161 mono_w32handle_timedwait_signal (guint32 timeout, gboolean poll, gboolean *alerted);
164 mono_w32handle_set_signal_state (gpointer handle, gboolean state, gboolean broadcast);
167 mono_w32handle_issignalled (gpointer handle);
170 mono_w32handle_lock_handle (gpointer handle);
173 mono_w32handle_trylock_handle (gpointer handle);
176 mono_w32handle_unlock_handle (gpointer handle);
179 mono_w32handle_lock_signal_mutex (void);
182 mono_w32handle_unlock_signal_mutex (void);
184 #endif /* !defined(HOST_WIN32) */
186 #endif /* _MONO_UTILS_W32HANDLE_H_ */