]> git.saurik.com Git - apple/objc4.git/blobdiff - runtime/objc-sync.mm
objc4-818.2.tar.gz
[apple/objc4.git] / runtime / objc-sync.mm
index d5dd019d4bffba8243338809c03ffd1872ff6f44..d29a822000c13474cb4fb2d6d080aaa28e4de9f6 100644 (file)
@@ -287,7 +287,7 @@ int objc_sync_enter(id obj)
 
     if (obj) {
         SyncData* data = id2data(obj, ACQUIRE);
-        assert(data);
+        ASSERT(data);
         data->mutex.lock();
     } else {
         // @synchronized(nil) does nothing
@@ -300,6 +300,25 @@ int objc_sync_enter(id obj)
     return result;
 }
 
+BOOL objc_sync_try_enter(id obj)
+{
+    BOOL result = YES;
+
+    if (obj) {
+        SyncData* data = id2data(obj, ACQUIRE);
+        ASSERT(data);
+        result = data->mutex.tryLock();
+    } else {
+        // @synchronized(nil) does nothing
+        if (DebugNilSync) {
+            _objc_inform("NIL SYNC DEBUG: @synchronized(nil); set a breakpoint on objc_sync_nil to debug");
+        }
+        objc_sync_nil();
+    }
+
+    return result;
+}
+
 
 // End synchronizing on 'obj'. 
 // Returns OBJC_SYNC_SUCCESS or OBJC_SYNC_NOT_OWNING_THREAD_ERROR