Skip to content

Commit

Permalink
Merge branch 'fix_multi-threading' of https://github.com/letiemble/mo…
Browse files Browse the repository at this point in the history
…nobjc into letiemble-fix_multi-threading
  • Loading branch information
letiemble committed Aug 31, 2013
2 parents 3c244c4 + 96088af commit c2ce9fb
Show file tree
Hide file tree
Showing 15 changed files with 202 additions and 37 deletions.
10 changes: 10 additions & 0 deletions native/Monobjc/Monobjc.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
4D8371CC17C680990065053F /* icalls-Monobjc.Foundation.NSString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D8371CA17C680990065053F /* icalls-Monobjc.Foundation.NSString.mm */; };
4D8371CD17C680990065053F /* icalls-Monobjc.Foundation.NSString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D8371CA17C680990065053F /* icalls-Monobjc.Foundation.NSString.mm */; };
4D8371CE17C680990065053F /* icalls-Monobjc.Foundation.NSString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D8371CA17C680990065053F /* icalls-Monobjc.Foundation.NSString.mm */; };
4D854B4017CE76DB00DDB5DB /* threading.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D854B3F17CE76DB00DDB5DB /* threading.mm */; };
4D854B4117CE76DB00DDB5DB /* threading.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D854B3F17CE76DB00DDB5DB /* threading.mm */; };
4D854B4217CE76DB00DDB5DB /* threading.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D854B3F17CE76DB00DDB5DB /* threading.mm */; };
4D854B4317CE76DB00DDB5DB /* threading.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D854B3F17CE76DB00DDB5DB /* threading.mm */; };
4D9CC07D11568E090027FF52 /* icalls-Monobjc.ObjectiveCEncoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D9CC07C11568E090027FF52 /* icalls-Monobjc.ObjectiveCEncoding.mm */; };
4D9CC07E11568E090027FF52 /* icalls-Monobjc.ObjectiveCEncoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D9CC07C11568E090027FF52 /* icalls-Monobjc.ObjectiveCEncoding.mm */; };
4D9E554617898AB400D7C497 /* blocks.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D9E554517898AB400D7C497 /* blocks.mm */; };
Expand Down Expand Up @@ -395,6 +399,7 @@
4D7C2B2E141D69C1008CF2AD /* support-os.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "support-os.h"; path = "sources/support-os.h"; sourceTree = "<group>"; };
4D7C2B30141D69CE008CF2AD /* support-os.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "support-os.mm"; path = "sources/support-os.mm"; sourceTree = "<group>"; };
4D8371CA17C680990065053F /* icalls-Monobjc.Foundation.NSString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "icalls-Monobjc.Foundation.NSString.mm"; path = "sources/icalls/icalls-Monobjc.Foundation.NSString.mm"; sourceTree = "<group>"; };
4D854B3F17CE76DB00DDB5DB /* threading.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = threading.mm; path = sources/threading.mm; sourceTree = "<group>"; };
4D9CC07C11568E090027FF52 /* icalls-Monobjc.ObjectiveCEncoding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "icalls-Monobjc.ObjectiveCEncoding.mm"; path = "sources/icalls/icalls-Monobjc.ObjectiveCEncoding.mm"; sourceTree = "<group>"; };
4D9E554517898AB400D7C497 /* blocks.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = blocks.mm; path = sources/blocks.mm; sourceTree = "<group>"; };
4DA5213F1159690A007C19C3 /* descriptor.def */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = descriptor.def; path = sources/descriptors/descriptor.def; sourceTree = "<group>"; };
Expand Down Expand Up @@ -635,6 +640,7 @@
87293E8D1153C0A2007AFD45 /* support-mono.mm */,
4D78F3861185B4CC00103C6C /* support-objc.mm */,
4D7C2B30141D69CE008CF2AD /* support-os.mm */,
4D854B3F17CE76DB00DDB5DB /* threading.mm */,
);
name = sources;
sourceTree = "<group>";
Expand Down Expand Up @@ -1140,6 +1146,7 @@
4D67819C1769980E00B8BBE7 /* logging.mm in Sources */,
4D67819D1769980E00B8BBE7 /* descriptor-System.Boolean.mm in Sources */,
4D67819E1769980E00B8BBE7 /* descriptor-System.Byte.mm in Sources */,
4D854B4117CE76DB00DDB5DB /* threading.mm in Sources */,
4D67819F1769980E00B8BBE7 /* descriptor-System.Char.mm in Sources */,
4D6781A01769980E00B8BBE7 /* descriptor-System.Int16.mm in Sources */,
4D6781A11769980E00B8BBE7 /* descriptor-System.Int32.mm in Sources */,
Expand Down Expand Up @@ -1173,6 +1180,7 @@
files = (
4D6781C61769981900B8BBE7 /* main.mm in Sources */,
4D6781C71769981900B8BBE7 /* support-mono.mm in Sources */,
4D854B4317CE76DB00DDB5DB /* threading.mm in Sources */,
4D6781C81769981900B8BBE7 /* monobjc.mm in Sources */,
4D6781C91769981900B8BBE7 /* icalls-Monobjc.Class.mm in Sources */,
4D6781CA1769981900B8BBE7 /* icalls-Monobjc.Id.mm in Sources */,
Expand Down Expand Up @@ -1243,6 +1251,7 @@
4D791AF81158037C0062C7E0 /* logging.mm in Sources */,
4DA521C7115A069F007C19C3 /* descriptor-System.Boolean.mm in Sources */,
4DA521C8115A069F007C19C3 /* descriptor-System.Byte.mm in Sources */,
4D854B4017CE76DB00DDB5DB /* threading.mm in Sources */,
4DA521C9115A069F007C19C3 /* descriptor-System.Char.mm in Sources */,
4DA521CA115A069F007C19C3 /* descriptor-System.Int16.mm in Sources */,
4DA521CB115A069F007C19C3 /* descriptor-System.Int32.mm in Sources */,
Expand Down Expand Up @@ -1276,6 +1285,7 @@
files = (
87293ED71153C24C007AFD45 /* main.mm in Sources */,
87293F691153CBE0007AFD45 /* support-mono.mm in Sources */,
4D854B4217CE76DB00DDB5DB /* threading.mm in Sources */,
87293F911153D870007AFD45 /* monobjc.mm in Sources */,
4DED6A921154C8C500AF687B /* icalls-Monobjc.Class.mm in Sources */,
4DED6A931154C8C500AF687B /* icalls-Monobjc.Id.mm in Sources */,
Expand Down
9 changes: 6 additions & 3 deletions native/Monobjc/sources/cache.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ static void __destroy_instance(void *value) {
#pragma mark ----- Implementation -----

void monobjc_create_caches() {
MONOBJC_MUTEX_INIT(&__INSTANCES_MUTEX, FALSE);
// This mutex is re-entrant and must maintain a lock count.
// For example, Class.Get() may invoke a managed constructor
// which may invoke Id.MapInstance() on the same thread.
monobjc_mutex_init(&__INSTANCES_MUTEX, TRUE);

LOG_INFO(MONOBJC_DOMAIN_GENERAL, "Create cache for instances");
__INSTANCES_HASHTABLE = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __destroy_instance);
Expand All @@ -64,7 +67,7 @@ void monobjc_destroy_caches() {
LOG_INFO(MONOBJC_DOMAIN_GENERAL, "Destroy cache for constructors");
g_hash_table_destroy(__CONSTRUCTORS_HASHTABLE);

MONOBJC_MUTEX_FREE(&__INSTANCES_MUTEX);
monobjc_mutex_destroy(&__INSTANCES_MUTEX);
}

static void __INSTANCES_HASHTABLE__GHFunc(gpointer key, gpointer value, gpointer user_data) {
Expand Down Expand Up @@ -120,6 +123,6 @@ void monobjc_cache_remove_instance(void *ptr) {
}

void monobjc_cache_remove_instance_in_domain(void *ptr, MonobjcDomainData *domain_data) {
LOG_DEBUG(MONOBJC_DOMAIN_INSTANCES, "Remove instance for %p in domain #%d", ptr, domain_data->identifier);
LOG_DEBUG(MONOBJC_DOMAIN_INSTANCES, "Remove instance for %p", ptr);
g_hash_table_remove(domain_data->INSTANCES_HASHTABLE, ptr);
}
31 changes: 24 additions & 7 deletions native/Monobjc/sources/domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,28 @@ typedef struct MonobjcDomainData {
} MonobjcDomainData;


/** @brief Mutex to protect domain data. */
extern pthread_mutex_t __DOMAINS_MUTEX;


/** @brief Shortcut macro for lock acquisition. */
#define LOCK_DOMAINS() monobjc_mutex_lock(&__DOMAINS_MUTEX)

/** @brief Shortcut macro for lock release. */
#define UNLOCK_DOMAINS() monobjc_mutex_unlock(&__DOMAINS_MUTEX)


/** @brief Shortcut accessor to the hashtable that serves as a cache for the calls. */
#define __CALLS_HASHTABLE monobjc_get_domain_data(mono_domain_get())->CALLS_HASHTABLE

/** @brief Shortcut accessor to the mutex for the calls' hashtable. */
#define __CALLS_MUTEX monobjc_get_domain_data(mono_domain_get())->CALLS_MUTEX

/** @brief Shortcut macro for lock acquisition. */
#define LOCK_CALLS() MONOBJC_MUTEX_LOCK(&__CALLS_MUTEX)
#define LOCK_CALLS() monobjc_mutex_lock(&__CALLS_MUTEX)

/** @brief Shortcut macro for lock release. */
#define UNLOCK_CALLS() MONOBJC_MUTEX_UNLOCK(&__CALLS_MUTEX)
#define UNLOCK_CALLS() monobjc_mutex_unlock(&__CALLS_MUTEX)


/** @brief Shortcut accessor to the hashtable that serves as a cache for the descriptors. */
Expand All @@ -85,10 +96,10 @@ typedef struct MonobjcDomainData {
#define __DESCRIPTORS_MUTEX monobjc_get_domain_data(mono_domain_get())->DESCRIPTORS_MUTEX

/** @brief Shortcut macro for lock acquisition. */
#define LOCK_DESCRIPTORS() MONOBJC_MUTEX_LOCK(&__DESCRIPTORS_MUTEX)
#define LOCK_DESCRIPTORS() monobjc_mutex_lock(&__DESCRIPTORS_MUTEX)

/** @brief Shortcut macro for lock release. */
#define UNLOCK_DESCRIPTORS() MONOBJC_MUTEX_UNLOCK(&__DESCRIPTORS_MUTEX)
#define UNLOCK_DESCRIPTORS() monobjc_mutex_unlock(&__DESCRIPTORS_MUTEX)


/** @brief Shortcut accessor to the hashtable that serves as a cache for the instances. */
Expand All @@ -97,11 +108,17 @@ typedef struct MonobjcDomainData {
/** @brief Shortcut accessor to the mutex for the instances' hashtable. */
#define __INSTANCES_MUTEX monobjc_get_domain_data(mono_domain_get())->INSTANCES_MUTEX

/** @brief Shortcut macro for lock acquisition. */
#define LOCK_INSTANCES() MONOBJC_MUTEX_LOCK(&__INSTANCES_MUTEX)
/** @brief Shortcut macro for lock acquisition.
* @remark Note that LOCK_DOMAINS() must always be called prior to LOCK_INSTANCES() to avoid
* deadlock since monobjc_remove_instance_in_domains acquires the __DOMAINS_MUTEX and
* waits on the __INSTANCES_MUTEX. The __INSTANCES_MUTEX can't be released from another
* thread if that thread doesn't hold the __DOMAINS_MUTEX because monobjc_get_domain_data
* has to take the __DOMAINS_MUTEX lock.
*/
#define LOCK_INSTANCES() LOCK_DOMAINS(); monobjc_mutex_lock(&__INSTANCES_MUTEX)

/** @brief Shortcut macro for lock release. */
#define UNLOCK_INSTANCES() MONOBJC_MUTEX_UNLOCK(&__INSTANCES_MUTEX)
#define UNLOCK_INSTANCES() monobjc_mutex_unlock(&__INSTANCES_MUTEX); UNLOCK_DOMAINS()


/** @brief Shortcut accessor to the hashtable that serves as a cache for the wrappers. */
Expand Down
23 changes: 17 additions & 6 deletions native/Monobjc/sources/domain.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@
* @date 2009-2013
*/
#include "cache.h"
#include "constants.h"
#include "domain.h"
#include "glib.h"
#include "logging.h"

pthread_mutex_t __DOMAINS_MUTEX;

/** @brief List of the domain data. */
static GSList *__DOMAINS_DATA = NULL;

Expand All @@ -41,22 +44,23 @@ void monobjc_create_domain_data() {
MonoDomain *domain = mono_domain_get();
MonobjcDomainData *data = monobjc_get_domain_data(domain);
if (data) {
LOG_ERROR(MONOBJC_DOMAIN_GENERAL, "Cannot call monobjc_create_domain_data twice.");
// This is fatal and cannot be handled. Raise an exception.
[NSException raise:[NSString stringWithUTF8String:OBJECTIVE_C_EXCEPTION] format:@"%@ Domain #%d - Thread #%u", @"Cannot call monobjc_create_domain_data twice.", data->identifier, MACH_THREAD_ID];
}
data = g_new(MonobjcDomainData, 1);
data->identifier = mono_domain_get_id(domain);
LOG_INFO(MONOBJC_DOMAIN_GENERAL, "Creating Monobjc domain data for domain #%d", data->identifier);
LOG_INFO(MONOBJC_DOMAIN_GENERAL, "Creating Monobjc domain data for domain #%d from thread #%u", data->identifier, MACH_THREAD_ID);
__DOMAINS_DATA = g_slist_append(__DOMAINS_DATA, data);
}

void monobjc_destroy_domain_data() {
MonoDomain *domain = mono_domain_get();
MonobjcDomainData *data = monobjc_get_domain_data(domain);
if (!data) {
LOG_ERROR(MONOBJC_DOMAIN_GENERAL, "Cannot call monobjc_destroy_domain_data on NULL data.");
}
else {
LOG_INFO(MONOBJC_DOMAIN_GENERAL, "Destroying Monobjc domain data for domain #%d", data->identifier);
// This is fatal and cannot be handled. Raise an exception.
[NSException raise:[NSString stringWithUTF8String:OBJECTIVE_C_EXCEPTION] format:@"%@ Domain #%d - Thread #%u", @"Cannot call monobjc_destroy_domain_data on NULL data.", mono_domain_get_id(domain), MACH_THREAD_ID];
} else {
LOG_INFO(MONOBJC_DOMAIN_GENERAL, "Destroying Monobjc domain data for domain #%d from thread #%u", data->identifier, MACH_THREAD_ID);
__DOMAINS_DATA = g_slist_remove(__DOMAINS_DATA, data);
g_free(data);
}
Expand All @@ -68,22 +72,29 @@ void monobjc_destroy_domain_data() {
}

int32_t identifier = mono_domain_get_id(domain);
LOCK_DOMAINS();
GSList *current = __DOMAINS_DATA;
while(current) {
MonobjcDomainData *data = (MonobjcDomainData *) current->data;
if (data->identifier == identifier) {
UNLOCK_DOMAINS();
return data;
}
current = g_slist_next(current);
}
UNLOCK_DOMAINS();
return NULL;
}

void monobjc_remove_instance_in_domains(void *ptr) {
LOCK_DOMAINS();
GSList *current = __DOMAINS_DATA;
while(current) {
MonobjcDomainData *data = (MonobjcDomainData *) current->data;
monobjc_mutex_lock(&data->INSTANCES_MUTEX);
monobjc_cache_remove_instance_in_domain(ptr, data);
monobjc_mutex_unlock(&data->INSTANCES_MUTEX);
current = g_slist_next(current);
}
UNLOCK_DOMAINS();
}
2 changes: 2 additions & 0 deletions native/Monobjc/sources/icalls/icalls-Monobjc.Id.mm
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,7 @@ void icall_Monobjc_Id_SetInstanceVariable(MonoType *type, void *ptr, MonoString
*/
void icall_Monobjc_Id_MapInstance(void *ptr, MonoObject *wrapper) {
LOG_INFO(MONOBJC_DOMAIN_INSTANCES, "icall_Monobjc_Id_MapInstance(%p)", ptr);
LOCK_INSTANCES();
monobjc_cache_map_instance(ptr, wrapper);
UNLOCK_INSTANCES();
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@
void icall_Monobjc_ObjectiveCRuntime_Bootstrap(void) {
LOG_INFO(MONOBJC_DOMAIN_GENERAL, "Bootstrapping the bridge...");

LOCK_DOMAINS();
monobjc_create_domain_data();

monobjc_create_definitions();
monobjc_create_default_descriptors();
monobjc_create_cache_for_calls();
monobjc_create_caches();
UNLOCK_DOMAINS();
}

/**
Expand All @@ -61,12 +62,13 @@ void icall_Monobjc_ObjectiveCRuntime_Bootstrap(void) {
void icall_Monobjc_ObjectiveCRuntime_CleanUp(void) {
LOG_INFO(MONOBJC_DOMAIN_GENERAL, "Cleaning up the bridge...");

LOCK_DOMAINS();
monobjc_destroy_caches();
monobjc_destroy_cache_for_calls();
monobjc_destroy_descriptors();
monobjc_destroy_definitions();

monobjc_destroy_domain_data();
UNLOCK_DOMAINS();
}

/**
Expand Down
11 changes: 11 additions & 0 deletions native/Monobjc/sources/lifecycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@
#ifndef __LIFECYCLE_H__
#define __LIFECYCLE_H__

#include "threading.h"

/** @brief Mutex around implementation table. */
extern pthread_mutex_t __IMPLEMENTATIONS_MUTEX;

/** @brief Shortcut macro for lock acquisition. */
#define LOCK_IMPLEMENTATIONS() monobjc_mutex_lock(&__IMPLEMENTATIONS_MUTEX)

/** @brief Shortcut macro for lock release. */
#define UNLOCK_IMPLEMENTATIONS() monobjc_mutex_unlock(&__IMPLEMENTATIONS_MUTEX)

/**
* @brief Setup the interception of the \c dealloc messages for the given class.
* @param cls The native class to intercept.
Expand Down
9 changes: 9 additions & 0 deletions native/Monobjc/sources/lifecycle.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "support-objc.h"
#include "threading.h"

pthread_mutex_t __IMPLEMENTATIONS_MUTEX;

/** @brief Hashtable that contains original implementations for dealloc messages. */
static GHashTable *__IMPLEMENTATIONS = NULL;

Expand All @@ -50,7 +52,9 @@ static void __dealloc_interceptor(id target, SEL name) {
LOG_DEBUG(MONOBJC_DOMAIN_INSTANCES, "Target Root Meta Class is %s", class_getName(root_meta_class));

// Get the implementation for the target root class
LOCK_IMPLEMENTATIONS();
IMP implementation = (IMP) g_hash_table_lookup(__IMPLEMENTATIONS, root_meta_class);
UNLOCK_IMPLEMENTATIONS();

// Remove the target in every domain
monobjc_remove_instance_in_domains(target);
Expand All @@ -65,6 +69,8 @@ static void __dealloc_interceptor(id target, SEL name) {
#pragma mark ----- Implementation -----

void monobjc_intercep_dealloc_for(Class cls) {
LOCK_IMPLEMENTATIONS();

if (!__IMPLEMENTATIONS) {
__IMPLEMENTATIONS = g_hash_table_new(g_direct_hash, g_direct_equal);
}
Expand All @@ -74,6 +80,7 @@ void monobjc_intercep_dealloc_for(Class cls) {

// Check if we already deal with the root meta class
if (g_hash_table_lookup(__IMPLEMENTATIONS, root_meta_class)) {
UNLOCK_IMPLEMENTATIONS();
return;
}

Expand All @@ -89,4 +96,6 @@ void monobjc_intercep_dealloc_for(Class cls) {

// Store the implementation in the map
g_hash_table_insert(__IMPLEMENTATIONS, root_meta_class, (void *) implementation);

UNLOCK_IMPLEMENTATIONS();
}
4 changes: 3 additions & 1 deletion native/Monobjc/sources/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@

#include "enumerations.h"

#define MACH_THREAD_ID pthread_mach_thread_np(pthread_self())

/** @brief Default message appended when an error is logged. */
#define BUGREPORT_MESSAGE "If this is not really the expected behavior, please report it to http://tracker.monobjc.net/"
#define BUGREPORT_MESSAGE "If this is not really the expected behavior, please report it to http://tracker.monobjc.net/"

/** @brief Holds the current level to log. */
extern MonobjcLogLevel monobjc_current_log_level;
Expand Down
4 changes: 2 additions & 2 deletions native/Monobjc/sources/logging.mm
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void monobjc_log(MonobjcLogLevel log_level, MonobjcLogDomain domain, const char
if (domain != NULL) {
domain_id = mono_domain_get_id(domain);
}
asl_log(NULL, monobjc_aslmsg, level, "[Domain #%d - Thread #%u] %s", domain_id, pthread_mach_thread_np(pthread_self()), msg);
asl_log(NULL, monobjc_aslmsg, level, "[Domain #%d - Thread #%u] %s", domain_id, MACH_THREAD_ID, msg);
free(msg);
}

Expand Down Expand Up @@ -151,7 +151,7 @@ void monobjc_logv(MonobjcLogLevel log_level, MonobjcLogDomain domain, const char
if (domain != NULL) {
domain_id = mono_domain_get_id(domain);
}
asl_log(NULL, monobjc_aslmsg, level, "[Domain #%d - Thread #%u] %s", domain_id, pthread_mach_thread_np(pthread_self()), msg);
asl_log(NULL, monobjc_aslmsg, level, "[Domain #%d - Thread #%u] %s", domain_id, MACH_THREAD_ID, msg);
free(msg);
}
}
Expand Down
4 changes: 2 additions & 2 deletions native/Monobjc/sources/marshal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void __map_descriptor(MonoType *type, MonobjcTypeDescriptor *descriptor) {

void monobjc_create_default_descriptors() {
LOG_INFO(MONOBJC_DOMAIN_GENERAL, "Create cache for descriptors");
MONOBJC_MUTEX_INIT(&__DESCRIPTORS_MUTEX, TRUE);
monobjc_mutex_init(&__DESCRIPTORS_MUTEX, TRUE);
__DESCRIPTORS_HASHTABLE = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, __destroy_descriptor);

// Create marshalers for Monobjc types
Expand Down Expand Up @@ -182,7 +182,7 @@ void monobjc_create_default_descriptors() {
void monobjc_destroy_descriptors() {
LOG_INFO(MONOBJC_DOMAIN_GENERAL, "Destroy cache for descriptors");
g_hash_table_destroy(__DESCRIPTORS_HASHTABLE);
MONOBJC_MUTEX_FREE(&__DESCRIPTORS_MUTEX);
monobjc_mutex_destroy(&__DESCRIPTORS_MUTEX);
}

MonobjcTypeDescriptor *monobjc_get_descriptor(MonoType *type, char *encoding, bool canFail) {
Expand Down
4 changes: 2 additions & 2 deletions native/Monobjc/sources/messaging.mm
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ static void __destroy_nativecallslot(void *value) {
void monobjc_create_cache_for_calls() {
LOG_INFO(MONOBJC_DOMAIN_GENERAL, "Create cache for calls");
__CALLS_HASHTABLE = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __destroy_nativecallslot);
MONOBJC_MUTEX_INIT(&__CALLS_MUTEX, FALSE);
monobjc_mutex_init(&__CALLS_MUTEX, FALSE);
}

void monobjc_destroy_cache_for_calls() {
LOG_INFO(MONOBJC_DOMAIN_GENERAL, "Destroy cache for calls");
g_hash_table_destroy(__CALLS_HASHTABLE);
MONOBJC_MUTEX_FREE(&__CALLS_MUTEX);
monobjc_mutex_destroy(&__CALLS_MUTEX);
}

MonobjcNativeCallSlot *monobjc_lookup_call(MonoType *return_type, SEL selector, MonoArray *parameters) {
Expand Down
Loading

0 comments on commit c2ce9fb

Please sign in to comment.