86590217c4d35bdcdbce1c6397f5fb849c88f10d
[mono.git] / mono / metadata / w32event-win32.c
1 /*
2  * w32event-win32.c: Runtime support for managed Event on Win32
3  *
4  * Author:
5  *      Ludovic Henry (luhenry@microsoft.com)
6  *
7  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
8  */
9
10 #include "w32event.h"
11
12 #include <windows.h>
13 #include <winbase.h>
14
15 void
16 mono_w32event_init (void)
17 {
18 }
19
20 gpointer
21 mono_w32event_create (gboolean manual, gboolean initial)
22 {
23         return CreateEvent (NULL, manual, initial, NULL);
24 }
25
26 void
27 mono_w32event_set (gpointer handle)
28 {
29         SetEvent (handle);
30 }
31
32 void
33 mono_w32event_reset (gpointer handle)
34 {
35         ResetEvent (handle);
36 }
37
38 gpointer
39 ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoString *name, gint32 *error)
40 {
41         gpointer event;
42
43         event = CreateEvent (NULL, manual, initial, name ? mono_string_chars (name) : NULL);
44
45         *error = GetLastError ();
46
47         return event;
48 }
49
50 gboolean
51 ves_icall_System_Threading_Events_SetEvent_internal (gpointer handle)
52 {
53         return SetEvent (handle);
54 }
55
56 gboolean
57 ves_icall_System_Threading_Events_ResetEvent_internal (gpointer handle)
58 {
59         return ResetEvent (handle);
60 }
61
62 void
63 ves_icall_System_Threading_Events_CloseEvent_internal (gpointer handle)
64 {
65         CloseHandle (handle);
66 }
67
68 gpointer
69 ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name, gint32 rights, gint32 *error)
70 {
71         gpointer handle;
72
73         *error = ERROR_SUCCESS;
74
75         handle = OpenEvent (rights, FALSE, mono_string_chars (name));
76         if (!handle)
77                 *error = GetLastError ();
78
79         return handle;
80 }