         let entry = ContainerEntry(serviceType: serviceType, factory: factory)
 
         // ensure no other access while writing
-        dispatch_barrier_sync(accessQueue) {
-            services[key] = entry
+        servicesLock.lock()
+
+        defer {
+            servicesLock.unlock()
         }
+
+        services[key] = entry
 
         return entry
     }

        var lockedEntry: ContainerItemType? = nil

        // read from data structure in a thread-safe manner
        dispatch_sync(accessQueue) {
            lockedEntry = services[key]
        }

        if let entry = lockedEntry as? ContainerEntry<T> {
            if entry.instance == nil {
                entry.instance = resolveEntry(entry, key: key, invoker: invoker) as Any
            }



    private var services = [ContainerItemKey: ContainerItemType]()

    // we need a recursive lock, because sometimes we do a resolve() inside a resolve()
    private let servicesLock = NSRecursiveLock()

    public func register<T>(serviceType: T.Type, name: String? = nil, factory: Resolvable -> T) -> ContainerEntry<T> {
        return registerFactory(serviceType, factory: factory, name: name)
