 
             // MARK: Private
 
-            private let executingCount: UnsafeMutablePointer<Int32> = .allocate(capacity: 1)
+            private let executingCount: AtomicInt = .init()
+
+            
+            // MARK: - AtomicInt
+            
+            fileprivate class AtomicInt {
+                
+                // MARK: FilePrivate
+
+                fileprivate func incrementAndGet() -> Int {
+
+                    self.lock.wait()
+                    defer {
+                        
+                        self.lock.signal()
+                    }
+                    self.value += 1
+                    return self.value
+                }
+
+                fileprivate func decrement() {
+
+                    self.lock.wait()
+                    defer {
+                        
+                        self.lock.signal()
+                    }
+                    self.value -= 1
+                }
+
+                
+                // MARK: Private
+
+                private let lock = DispatchSemaphore(value: 1)
+                private var value = 0
+            }
         }
         
     }

                            return
                        }
                        action()
                        OSAtomicDecrement32(self.executingCount)
                    }
                }
            }


            // MARK: FilePrivate

            fileprivate init() {}

            fileprivate func dispatch(_ action: @escaping () -> Void) {

                let count = self.executingCount.incrementAndGet()
                if Thread.isMainThread && count == 1 {

                    action()
                    self.executingCount.decrement()
                }
                else {

