         return self
     }
     
-    var internalState: State = .Initialized
-    
     var state: State {
         get {
             return Dispatch.sync(queue) { return self.internalState }

import class Foundation.NSOperation

public class Task<T>: NSOperation {
    @objc class func keyPathsForValuesAffectingIsReady() -> Set<NSObject> {
        return ["state"]
    }
    
    @objc class func keyPathsForValuesAffectingIsExecuting() -> Set<NSObject> {
        return ["state"]
    }
    
    @objc class func keyPathsForValuesAffectingIsFinished() -> Set<NSObject> {
        return ["state"]
    }
    
    let queue = dispatch_queue_create("io.overdrive.task", nil)
    
    var internalResult: Result<T>?
    
    public var result: Result<T>? {
        get {
            return Dispatch.sync(queue) {
                return self.internalResult
            }
        }
        
        set(newResult) {

    public override init() {
        super.init()
    }
    
    //MARK: KVO mechanisms
    
    @objc class func keyPathsForValuesAffectingIsReady() -> Set<NSObject> {
        return ["state"]
    }
    
    @objc class func keyPathsForValuesAffectingIsExecuting() -> Set<NSObject> {
        return ["state"]
    }
    
    @objc class func keyPathsForValuesAffectingIsFinished() -> Set<NSObject> {
        return ["state"]
    }
}
