pub struct ProcessStartArgs {
pub next_handlers_count: usize,
pub yield_count: u16,
/* private fields */
}Expand description
Arguments for on_process_start handlers.
Empty in this release.
Fields§
§next_handlers_count: usizeNumber of start handlers yet to run.
yield_count: u16Number of times this handler has yielded.
If this exceeds 32 times the handler is ignored.
Implementations§
Source§impl ProcessStartArgs
impl ProcessStartArgs
Sourcepub const MAX_YIELD_COUNT: u16 = 32
pub const MAX_YIELD_COUNT: u16 = 32
Yield requests after this are ignored.
Sourcepub fn yield_once(&self)
pub fn yield_once(&self)
Let other process start handlers run first.
The handler must call this if it takes over the process and it cannot determinate if it should from the environment.
fn run_foo_process() {}
on_process_start!(|args| {
if args.yield_count == 0 {
return args.yield_once();
}
// yielded once, handlers that affect all processes (loggers, tracers) are inited now
if std::env::var("IS_FOO").is_ok() {
// take over as "foo" process
run_foo_process();
zng_env::exit(0);
}
});Sourcepub fn yield_until_app(&self) -> bool
pub fn yield_until_app(&self) -> bool
Yields until is running the the app-process.
Returns true if should skip the handler.
on_process_start!(|args| {
if args.yield_until_app() {
return;
}
println!("Is running in the app-process");
});Note that the handler is still called before the APP context starts, you can register a APP.on_init handler
to run in the new app context.
Auto Trait Implementations§
impl !Freeze for ProcessStartArgs
impl RefUnwindSafe for ProcessStartArgs
impl Send for ProcessStartArgs
impl Sync for ProcessStartArgs
impl Unpin for ProcessStartArgs
impl UnwindSafe for ProcessStartArgs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more