3 * Runtime support for managed Mutex on Win32
6 * Ludovic Henry (luhenry@microsoft.com)
8 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
15 #include <mono/metadata/handle.h>
16 #include <mono/utils/mono-error-internals.h>
20 mono_w32mutex_init (void)
25 ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoStringHandle name, MonoBoolean *created, MonoError *error)
33 if (MONO_HANDLE_IS_NULL (name)) {
35 mutex = CreateMutex (NULL, owned, NULL);
39 gunichar2 *uniname = mono_string_handle_pin_chars (name, &gchandle);
41 mutex = CreateMutex (NULL, owned, uniname);
43 if (GetLastError () == ERROR_ALREADY_EXISTS)
46 mono_gchandle_free (gchandle);
53 ves_icall_System_Threading_Mutex_ReleaseMutex_internal (gpointer handle)
55 return ReleaseMutex (handle);
59 ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoStringHandle name, gint32 rights, gint32 *err, MonoError *error)
66 uint32_t gchandle = 0;
67 gunichar2 *uniname = NULL;
68 if (!MONO_HANDLE_IS_NULL (name))
69 uniname = mono_string_handle_pin_chars (name, &gchandle);
71 ret = OpenMutex (rights, FALSE, uniname);
73 *err = GetLastError ();
76 mono_gchandle_free (gchandle);