[swift-evolution] LibDispatch : access to current queue, or queue name

Ben Rimmington me at benrimmington.com
Mon Jun 20 04:02:39 CDT 2016


> On 19 Jun 2016, at 23:52, Jérôme Duquennoy via swift-evolution <swift-evolution at swift.org> wrote:
> 
> With the release of swift 3, The interface to libDispatch has evolved quite a lot, to a much cleaner, object oriented interface.
> There seems to be one feature that is no longer available :
> In swift 2, it was possible to get the current queue label using "dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL)".
> 
> In the new interface, the DispatchQueue has a label property, but there seems to be no way to get the current queue.
> 
> Is that a design decision ?

[Cc: Matt Wright]

> If not, a "current" class property should probably be added to "DispatchQueue".

`DispatchQueue.current` is unlikely to be accepted, because `dispatch_get_current_queue()` is deprecated (since iOS 6.0, macOS 10.9).

> If yes, maybe we could add a "currentQueueLabel" class property to "DispatchQueue", but this doesn't look right to me : why should only this property of the current queue be available, and not other ones like "qos" ?

`DispatchQueue.currentQueueLabel` might be useful for debugging and logging. Or maybe this would be better as an LLDB command or breakpoint action?

The new SE-0088 types don't seem to have CustomStringConvertible or CustomDebugStringConvertible conformance.

-- Ben


More information about the swift-evolution mailing list