i don't think it is provided by the system already so i'd like to implement a smart version of DispatchQueue.async function - the one that will not reschedule the block if i am already on the queue in question and call the block directly instead in this case.
Code Block extension DispatchQueue { func asyncSmart(execute: @escaping () -> Void) { if DispatchQueue.current === self { // ????? execute() } else { async(execute: execute) } } }
the immediate problem is that there is no way to get the current queue (in order to compare it with the queue parameter and do the logic branch).
anyone've been through it and solved this puzzle?