         for info in selectorInfos {
             DefaultCenter.removeObserver(self, name: info.name, object: info.object)
         }
-        
-        OSSpinLockLock(&lock)
-        
-        blockInfos.removeAll(keepCapacity: false)
-        
-        OSSpinLockUnlock(&lock)
+
+        lockWith {
+            blockInfos.removeAll(keepCapacity: false)
+        }
+    }
+    
+    // MARK: Lock
+    
+    func lockWith(@noescape closure: Void -> Void) {
+        pthread_mutex_lock(&lock);
+        closure();
+        pthread_mutex_unlock(&lock);
     }
 }
 

    }
}

/// The notification handler response for handing all the hard work of observe and unoberve notifications.
/// The basic usage is rather similar to the official `NSNotification Center`
public class NotificationHandler: NSObject {
    public typealias NotificationClosure = (NSNotification!) -> Void
    
    private weak var observer: NSObject!
    private var blockInfos = Set<NotificationInfo>()
    private var selectorInfos = Set<NotificationInfo>()
    private var lock = OS_SPINLOCK_INIT
    
    private var DefaultCenter: NSNotificationCenter {
        return NSNotificationCenter.defaultCenter()

    // MARK: Initialization
    
    /**
    Create a notification handler instance using the observer. Observer is responded for hold that instance. Normally, you don't need to call this method manually.
    
    - parameter observer: The observer will be weak referenced by that instance.
    
    - returns: An initialized instance
    */
    init (observer: NSObject) {
        pthread_mutex_init(&lock, nil)
        self.observer = observer
    }
    
