Skip to content

Getting the queue back out of an AnyScheduler? #36

Answered by mbrandonw
JetForMe asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @JetForMe, this is a good question!

Unfortunately it is not safe to expose a dispatch queue inside the AnyScheduler because it's not necessarily always powered by a real life dispatch queue. You can have a AnySchedulerOf<DispatchQueue> that secretly is a test scheduler or immediate scheduler under the hood, and so there is not real dispatch queue to expose.

The best we could do is expose a var base: Any that exposes the underlying scheduler, but it would have to be Any because the type of the underlying scheduler has been completely forgotten about... which is the point of the AnyScheduler. But, if you try casting that Any to a DispatchQueue it will fail in tests because most likely y…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JetForMe
Comment options

Answer selected by JetForMe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants