         return result
     }
     
+    /// Compare and set Object with barrier.
+    @_transparent
+    public func compareSet(oldVal: Atomic, _ newVal: Atomic) -> Bool {
+        return compareSet(oldVal.base, newVal.base)
+    }
+}
+
+extension Atomic {
+    
     /// Sets the value.
     @_transparent
-    public func setValue(@noescape block: (T) throws -> T) rethrows -> T {
+    public func setValue(@noescape block: (Instance) throws -> Instance) rethrows -> Instance {
         while true {
-            let oldVal = value
-            if self.compareSet(oldVal, try block(oldVal)) {
-                return oldVal
+            let oldVal = self.base
+            if self.compareSet(oldVal, AtomicBase(value: try block(oldVal.value))) {
+                return oldVal.value
             }
         }
     }
     
     /// Sets the value, and returns the previous value.
     @_transparent
-    public func fetchStore(value: T) -> T {
+    public func fetchStore(value: Instance) -> Instance {
         return self.setValue { _ in value }
     }
 }
 
-extension Atomic : SDAtomicType {
-    
-    /// Compare and set Object with barrier.
-    @_transparent
-    public func compareSet(oldVal: Atomic, _ newVal: Atomic) -> Bool {
-        return compareSet(oldVal.value, newVal.value)
+extension Atomic: CustomStringConvertible, CustomDebugStringConvertible {
+    
+    public var description: String {
+        return "Atomic(\(value))"
+    }
+    
+    public var debugDescription: String {
+        return "Atomic(\(value))"
     }
 }
 

    /// - Note: the hash value is not guaranteed to be stable across
    ///   different invocations of the same program.  Do not persist the
    ///   hash value across program runs.
    public var hashValue: Int {
        return boolValue.hashValue
    }

    @_transparent
    public mutating func compareSet<T: BooleanType>(oldVal: T, _ newVal: T) -> Bool {
        return self.val.compareSet(oldVal ? 0x80 : 0, newVal ? 0x80 : 0)
    }
}

extension AtomicBoolean: CustomStringConvertible, CustomDebugStringConvertible {
    
    public var description: String {
        return self ? "true" : "false"
    }
    
    public var debugDescription: String {
        return self ? "true" : "false"
    }
}

