-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Concurrency] Updates after second SE pitch. #82456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@swift-ci Please smoke test |
2a19c34
to
8c00ea0
Compare
@swift-ci Please smoke test |
/// | ||
/// Parameters: | ||
/// | ||
/// - from duration: The `Duration` to convert | ||
/// - job: The job we wish to run | ||
/// - at instant: The time at which we would like it to run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does spelling params like this actually parse well in docc? I thought one has to put only the second name 🤔
/// given instant. | ||
/// | ||
/// The default implementation uses the `run` method to trigger a job that | ||
/// does `executor.enqueue(job)`. If a particular `Clock` knows that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor
/// does `executor.enqueue(job)`. If a particular `Clock` knows that the | |
/// does `executor.enqueue(job)`. If a particular ``Clock`` knows that the |
maybe worth ref like that?
run(trampoline, at: instant, tolerance: tolerance) | ||
} | ||
|
||
// Clocks that do not implement run will fatalError() if you try to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Clocks that do not implement run will fatalError() if you try to use | |
// Clocks that do not implement this method will fatalError() if you try to use |
maybe? "implement run" sounds a bit weird mid-sentence
// Convert to `Swift.Duration` | ||
let duration = clock.convert(from: delay)! | ||
let duration = delay as! Swift.Duration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we put a comment here discussing the as!
's risk, could it ever fail?
// executor. | ||
extension ExecutorJob { | ||
|
||
/// Create a trampoline to enqueue the specified job on the specified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor?
/// Create a trampoline to enqueue the specified job on the specified | |
/// Create a trampoline to enqueue this job on the specified |
/// Create a trampoline to enqueue the specified job on the specified | ||
/// executor. | ||
/// | ||
/// This is useful in conjunction with the `Clock.run()` API, which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this'll link well:
/// This is useful in conjunction with the `Clock.run()` API, which | |
/// This is useful in conjunction with the ``Clock.run(_:at:tolerance:)`` API, which |
/// | ||
/// Returns: | ||
/// | ||
/// A new ExecutorJob that will enqueue the specified job on the specified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// A new ExecutorJob that will enqueue the specified job on the specified | |
// - Returns: A new ExecutorJob that will enqueue the specified job on the specified |
needs the -
I think?
/// This is useful in conjunction with the `Clock.run()` API, which | ||
/// runs a job on an unspecified executor. | ||
/// | ||
/// Parameters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Parameters: | |
/// - Parameters: |
Needs the -
I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, sorry about the docs nitpicks! I don't actually have a great way to preview those in tree I guess 🤔
No worries. I think you're right about the doc comments; I'll go and update them all. |
We no longer attempt to convert timestamps from the passed-in `Clock` in order to allow any clock to work with any executor. Instead, executors that do not recognise a clock should call the `enqueue` function on that `Clock`, which lets the `Clock` itself decide how to proceed. Additionally, rename `SchedulableExecutor` to `SchedulingExecutor`.
…cks. The built-in clocks should have implementations of `run` and `enqueue`, to allow derived clocks to call those implementations.
I don't think we actually need this. If you have a non-canonical (i.e. derived) clock, you can just implement `enqueue` and/or `run` and call those methods on the clock you're wrapping.
If a job enqueues another job on the executor, we might never leave the inner `while` loop in the `run()` method. Fix this by taking the contents of the run queue and only running those jobs in the queue at the time we enter the inner loop.
Add some documentation comments to the Dispatch and CF executors, and update the comments for the allocation and private data APIs.
Rather than just looking at top level in the module, start by searching the type marked as `@main`. This means that a library that provides a protocol or superclass that the `@main` type can conform to can specify an executor in a reasonable manner.
Also add `final` to the `CooperativeExecutor` declaration.
38ead6d
to
262f07a
Compare
(Haven't updated doc comments yet; that's the next job…) |
Some formatting fixes for the doc comments.
We're changing our approach to
Clock
support in executors such that a clock that isn't recognised by an executor will result in a call to anenqueue
method onClock
itself; this will allow clocks to have control over exactly how they schedule jobs in cases where the executor doesn't already know what to do.Also includes a small bug fix for
CooperativeExecutor
and some updated comments.rdar://154191435