GCD : Getting current dispatch queue name with swift 3

Hi all,

I'm migrating one of my project to Swift 3 (xcode 8 beat release).
Most of the changes were pretty strait-forward, but I have one required change that is still blocking me :
In my code, I retrieve the current dispatch queue name using that code :

let queueName = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL)

DispatchQueue objects do have a label attribute, but I cannot find how to get the current dispatch queue.
What would be the equivalent of it in swift 3 ?

Any idea would be very welcome :-).

Jérôme Duquennoy

I'm migrating one of my project to Swift 3 (xcode 8 beat release).
Most of the changes were pretty strait-forward, but I have one required change that is still blocking me :
In my code, I retrieve the current dispatch queue name using that code :

let queueName = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL)

DispatchQueue objects do have a label attribute, but I cannot find how to get the current dispatch queue.
What would be the equivalent of it in swift 3 ?

Any idea would be very welcome :-).

Here's a horrible workaround:

  extension DispatchQueue {
    class var currentLabel: String {
      return String(validatingUTF8: __dispatch_queue_get_label(nil))
    }
  }

But I think this is a hole in the current design. I'm not sure if it's an *intentional* hole or not; the concept of a "current queue" in general is a bit squirrelly.

···

--
Brent Royal-Gordon
Architechies

I'm migrating one of my project to Swift 3 (xcode 8 beat release).
Most of the changes were pretty strait-forward, but I have one required change that is still blocking me :
In my code, I retrieve the current dispatch queue name using that code :

let queueName = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL)

DispatchQueue objects do have a label attribute, but I cannot find how to get the current dispatch queue.
What would be the equivalent of it in swift 3 ?

Any idea would be very welcome :-).

Here's a horrible workaround:

  extension DispatchQueue {
    class var currentLabel: String {
      return String(validatingUTF8: __dispatch_queue_get_label(nil))
    }
  }

But I think this is a hole in the current design. I'm not sure if it's an *intentional* hole or not; the concept of a "current queue" in general is a bit squirrelly.

You should probably file a radar explaining what you want to do with this call.

···

--
Brent Royal-Gordon
Architechies