Ejemplo n.º 1
0
gpointer
ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoStringHandle name, MonoBoolean *created, MonoError *error)
{
	gpointer mutex;

	*created = TRUE;

	/* Need to blow away any old errors here, because code tests
	 * for ERROR_ALREADY_EXISTS on success (!) to see if a mutex
	 * was freshly created */
	mono_w32error_set_last (ERROR_SUCCESS);

	if (MONO_HANDLE_IS_NULL (name)) {
		mutex = mutex_create (owned);
	} else {
		gchar *utf8_name = mono_string_handle_to_utf8 (name, error);
		return_val_if_nok (error, NULL);

		mutex = namedmutex_create (owned, utf8_name);

		if (mono_w32error_get_last () == ERROR_ALREADY_EXISTS)
			*created = FALSE;
		g_free (utf8_name);
	}

	return mutex;
}
Ejemplo n.º 2
0
gpointer
ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoString *name, MonoBoolean *created)
{
	gpointer mutex;

	*created = TRUE;

	/* Need to blow away any old errors here, because code tests
	 * for ERROR_ALREADY_EXISTS on success (!) to see if a mutex
	 * was freshly created */
	mono_w32error_set_last (ERROR_SUCCESS);

	if (!name) {
		mutex = mutex_create (owned);
	} else {
		mutex = namedmutex_create (owned, mono_string_chars (name));

		if (mono_w32error_get_last () == ERROR_ALREADY_EXISTS)
			*created = FALSE;
	}

	return mutex;
}