     let timer:Timer = Timer.fromHandle(handle)
     timer.callback(timer)
 }
+
+extension Timeout {
+    init(uvTimeout:UInt64) {
+        switch uvTimeout {
+        case 0:
+            self = .Immediate
+        case UInt64.max:
+            self = .Infinity
+        default:
+            self = .In(timeout: Double(uvTimeout) / 1000)
+        }
+    }
+    
+    var uvTimeout:UInt64 {
+        get {
+            switch self {
+            case .Immediate:
+                return 0
+            case .Infinity:
+                return UInt64.max
+            case .In(let timeout):
+                return UInt64(timeout * 1000)
+            }
+        }
+    }
+}

        }
    }
    
    public var repeatTimeout:UInt64 {
        //uv_timer_get_repeat
        get {
            return handle.isNil() ? 0 : uv_timer_get_repeat(handle)
        }
        //uv_timer_set_repeat
        set {
            if !handle.isNil() {
                uv_timer_set_repeat(handle, newValue)
            }
        }
    }

    }
    
    //uv_timer_start
    public func start(timeout:Timeout, repeatTimeout:Timeout? = nil) throws {
        try doWithHandle { handle in
            let repeatTimeout = repeatTimeout ?? .Immediate
            try Error.handle {
                uv_timer_start(handle, timer_cb, timeout.uvTimeout, repeatTimeout.uvTimeout)
            }
        }
    }
