2 #ifndef _MONO_METADATA_W32HANDLE_H_
3 #define _MONO_METADATA_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,
33 MONO_W32HANDLE_WAIT_RET_SUCCESS_0 = 0,
34 MONO_W32HANDLE_WAIT_RET_ABANDONED_0 = MONO_W32HANDLE_WAIT_RET_SUCCESS_0 + MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS,
35 MONO_W32HANDLE_WAIT_RET_ALERTED = -1,
36 MONO_W32HANDLE_WAIT_RET_TIMEOUT = -2,
37 MONO_W32HANDLE_WAIT_RET_FAILED = -3,
38 } MonoW32HandleWaitRet;
42 void (*close)(gpointer handle, gpointer data);
44 /* SignalObjectAndWait */
45 void (*signal)(gpointer signal);
47 /* Called by WaitForSingleObject and WaitForMultipleObjects,
48 * with the handle locked (shared handles aren't locked.)
49 * Returns TRUE if ownership was established, false otherwise.
50 * If TRUE, *statuscode contains a status code such as
51 * WAIT_OBJECT_0 or WAIT_ABANDONED_0.
53 gboolean (*own_handle)(gpointer handle, guint32 *statuscode);
55 /* Called by WaitForSingleObject and WaitForMultipleObjects, if the
56 * handle in question is "ownable" (ie mutexes), to see if the current
57 * thread already owns this handle
59 gboolean (*is_owned)(gpointer handle);
61 /* Called by WaitForSingleObject and WaitForMultipleObjects,
62 * if the handle in question needs a special wait function
63 * instead of using the normal handle signal mechanism.
64 * Returns the WaitForSingleObject return code.
66 MonoW32HandleWaitRet (*special_wait)(gpointer handle, guint32 timeout, gboolean *alerted);
68 /* Called by WaitForSingleObject and WaitForMultipleObjects,
69 * if the handle in question needs some preprocessing before the
72 void (*prewait)(gpointer handle);
74 /* Called when dumping the handles */
75 void (*details)(gpointer data);
77 /* Called to get the name of the handle type */
78 const gchar* (*typename) (void);
80 /* Called to get the size of the handle type */
81 gsize (*typesize) (void);
85 MONO_W32HANDLE_CAP_WAIT = 0x01,
86 MONO_W32HANDLE_CAP_SIGNAL = 0x02,
87 MONO_W32HANDLE_CAP_OWN = 0x04,
88 MONO_W32HANDLE_CAP_SPECIAL_WAIT = 0x08,
89 } MonoW32HandleCapability;
91 extern guint32 mono_w32handle_fd_reserve;
94 mono_w32handle_init (void);
97 mono_w32handle_cleanup (void);
100 mono_w32handle_register_ops (MonoW32HandleType type, MonoW32HandleOps *ops);
103 mono_w32handle_new (MonoW32HandleType type, gpointer handle_specific);
106 mono_w32handle_new_fd (MonoW32HandleType type, int fd, gpointer handle_specific);
109 mono_w32handle_get_type (gpointer handle);
112 mono_w32handle_get_typename (MonoW32HandleType type);
115 mono_w32handle_lookup (gpointer handle, MonoW32HandleType type, gpointer *handle_specific);
118 mono_w32handle_foreach (gboolean (*on_each)(gpointer handle, gpointer data, gpointer user_data), gpointer user_data);
121 mono_w32handle_dump (void);
124 mono_w32handle_ref (gpointer handle);
127 mono_w32handle_unref (gpointer handle);
130 mono_w32handle_register_capabilities (MonoW32HandleType type, MonoW32HandleCapability caps);
133 mono_w32handle_test_capabilities (gpointer handle, MonoW32HandleCapability caps);
136 mono_w32handle_force_close (gpointer handle, gpointer data);
139 mono_w32handle_set_signal_state (gpointer handle, gboolean state, gboolean broadcast);
142 mono_w32handle_issignalled (gpointer handle);
145 mono_w32handle_lock_handle (gpointer handle);
148 mono_w32handle_trylock_handle (gpointer handle);
151 mono_w32handle_unlock_handle (gpointer handle);
154 mono_w32handle_wait_one (gpointer handle, guint32 timeout, gboolean alertable);
157 mono_w32handle_wait_multiple (gpointer *handles, gsize nhandles, gboolean waitall, guint32 timeout, gboolean alertable);
160 mono_w32handle_signal_and_wait (gpointer signal_handle, gpointer wait_handle, guint32 timeout, gboolean alertable);
162 #endif /* _MONO_METADATA_W32HANDLE_H_ */