This is a third pitch for the ability to write custom default executors (both the main executor, as used for the main actor, and the global executor, used by default for Swift Task
s). You can find the first pitch and the second pitch here.
The draft Custom Main and Global Executors PR has been updated with the following changes following feedback from the second pitch:
Clock
s no longer supportInstant
orDuration
conversion.- Instead,
Clock
has grownrun(_ job:at instant:tolerance:clock:)
andenqueue(_ job:on executor:at instant:tolerance:)
methods.- These allow an executor that finds itself asked to schedule a job using a
Clock
it doesn't recognise to hand the problem off to thatClock
, the idea being that theClock
will know how to do the right thing.
- These allow an executor that finds itself asked to schedule a job using a
- Expose the built-in executor implementations.
- Update the text surrounding the task allocator and executor private data to indicate that these facilities are only for use until the point at which a
Job
is executed. Executors much release any resources prior to that point, and in the case of the task allocator, must do so in strict reverse order of allocation.