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

Gwynne Raskind gwynne at darkrainfall.org
Mon Jun 20 04:14:54 CDT 2016

dispatch_queue_get_label() isn’t marked as a for-debugging-only API as far as I can see, and I can see uses in non-debugging contexts (logging is the obvious one) for knowing the current queue’s label (without also allowing the error-prone usage of dispatch_get_current_queue() itself). As such, I wouldn’t mind seeing this interface available on DispatchQueue, though I might name it simply "label", as in:

extension DispatchQueue {
	public class var label: String { get }

This would be in keeping with the way getSpecific() is named; IMO "DispatchQueue.label" is not ambiguous enough to require the extra "currentQueue" prefix. Or maybe "currentLabel", since if nothing else "queue" seems like noise to me, due to the repetition.

-- Gwynne Raskind

> On Jun 20, 2016, at 04:02, Ben Rimmington via swift-evolution <swift-evolution at swift.org> wrote:
>> 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
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list