[swift-evolution] [Review] SE-0088: Modernize libdispatch for Swift 3 naming conventions

Ben Rimmington me at benrimmington.com
Thu May 12 16:25:44 CDT 2016


<https://github.com/apple/swift-evolution/blob/master/proposals/0088-libdispatch-for-swift3.md>

> On 12 May 2016, at 19:03, Matt Wright <mww at apple.com> wrote:
> 
> Are you talking about ambiguity at a compiler level, or in human-reading?

I meant ambiguous for people familiar with libdispatch. For example, the `interval`, `leeway`, and `delta` parameters of the following are all in nanoseconds:

* dispatch_io_set_interval
* dispatch_source_set_timer
* dispatch_time
* dispatch_walltime

```
_ = DispatchTime.now() + 3_500_000_000 // 3.5 seconds or 111 years?
_ = DispatchTime.now() + .seconds(3.5) // OK
```

The other associated value types were changed (from Int to Int64) to support 32-bit platforms.

DISPATCH_TIME_FOREVER can also be represented as an optional parameter:

```
func wait(timeout: DispatchTime? = nil)
```

Is it possible to eliminate the DispatchWalltime type?

```
public struct DispatchTime {

    private let _value: dispatch_time_t

    public init() {
        _value = dispatch_time(DISPATCH_TIME_NOW, 0)
    }

    public init(walltime: UnsafePointer<timespec>?) {
        _value = dispatch_walltime(walltime, 0)
    }
}
```

-- Ben



More information about the swift-evolution mailing list