A default actor's executor does not conform to TaskExecutor
so you can't write the sample as written.
In whichever "fast path" or "slow path" you wrote out the order is always: "got first", "exit".
There is no concurrency introduced by your code snippet. The snippet is also missing an await which would make this more clear: AWAIT withTaskExecutor(...) { }
.
The "immediately" doesn't matter to withTaskExecutor
in a way because there is no new task created at all. We simply hop the current task to the provided executor -- in that sense yeah it is "immediately" but no different than any other async function.
This does apply to Task(on:)
because that "creates a task". And the difference is that normally Task { await actor.hopSomewhere() }
ALWAYS first gets executed on the global concurrency pool and then will hop to wherever the async function needs it to go.
The Task(on: taskExecutor)
immediately enqueues on taskExecutor
rather than first enqueueing on the global pool.