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 (MonoString *name, gint32 rights, gint32 *error)
63 *error = ERROR_SUCCESS;
65 ret = OpenMutex (rights, FALSE, mono_string_chars (name));
67 *error = GetLastError ();