-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change adds LocalRuntime, a new unstable runtime type which cannot be transferred across thread boundaries and supports spawn_local when called from the thread which owns the runtime. The initial set of docs for this are iffy. Documentation is absent right now at the module level, with the docs for the LocalRuntime struct itself being somewhat duplicative of those for the `Runtime` type. This can be addressed later as stabilization nears. This API has a few interesting implementation details: - because it was considered beneficial to reuse the same Handle as the normal runtime, it is possible to call spawn_local from a runtime context while on a different thread from the one which drives the runtime and owns it. This forces us to check the thread ID before attempting a local spawn. - An empty LocalOptions struct is passed into the build_local method in order to build the runtime. This will eventually have stuff in it like hooks. Relates to #6739.
- Loading branch information
1 parent
5ada511
commit 512e9de
Showing
12 changed files
with
760 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mod runtime; | ||
|
||
mod options; | ||
|
||
pub use options::LocalOptions; | ||
pub use runtime::LocalRuntime; | ||
pub(super) use runtime::LocalRuntimeScheduler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use std::marker::PhantomData; | ||
|
||
/// `LocalRuntime`-only config options | ||
/// | ||
/// Currently, there are no such options, but in the future, things like `!Send + !Sync` hooks may | ||
/// be added. | ||
#[derive(Default, Debug)] | ||
#[non_exhaustive] | ||
pub struct LocalOptions { | ||
/// Marker used to make this !Send and !Sync. | ||
_phantom: PhantomData<*mut u8>, | ||
} |
Oops, something went wrong.