pub struct Environment;
Implementations§
Source§impl Environment
impl Environment
pub const ENFORCE_ALLOWED_SCHEDULER_ROLES: u32 = 1u32
Sourcepub fn start(options: u32) -> Result<Environment, Status>
pub fn start(options: u32) -> Result<Environment, Status>
Start the driver runtime. This sets up the initial thread that the dispatchers run on.
Sourcepub fn new_driver<T>(&self, driver: *const T) -> Driver<T>
pub fn new_driver<T>(&self, driver: *const T) -> Driver<T>
Creates a new driver. It is expected that the driver passed in is a leaked pointer which will only be recovered by triggering the shutdown method on the driver.
§Panics
This method will panic if |driver| is not null.
Sourcepub fn with_current_driver<R>(
f: impl FnOnce(Option<DriverRefTypeErased<'_>>) -> R,
) -> R
pub fn with_current_driver<R>( f: impl FnOnce(Option<DriverRefTypeErased<'_>>) -> R, ) -> R
Calls |f| with the driver on top of the the thread’s current call stack. If no drivers ar currently on the stack, it will pass in None instead.
Sourcepub fn reset(&self)
pub fn reset(&self)
Resets the driver runtime to zero threads. This may only be called when there are no existing dispatchers.
§Panics
This method should not be called from a thread managed by the driver runtime, such as from tasks or ChannelRead callbacks.
Sourcepub fn destroy_all_dispatchers(&self)
pub fn destroy_all_dispatchers(&self)
Destroys all dispatchers in the process and blocks the current thread until each runtime dispatcher in the process is observed to have been destroyed.
This should only be used called after all drivers have been shutdown.
§Panics
This method should not be called from a thread managed by the driver runtime, such as from tasks or ChannelRead callbacks.
Sourcepub fn dispatcher_has_queued_tasks(&self, dispatcher: DispatcherRef<'_>) -> bool
pub fn dispatcher_has_queued_tasks(&self, dispatcher: DispatcherRef<'_>) -> bool
Returns whether the dispatcher has any queued tasks.
Sourcepub fn get_thread_limit(&self, scheduler_role: &str) -> u32
pub fn get_thread_limit(&self, scheduler_role: &str) -> u32
Returns the current maximum number of threads which will be spawned for thread pool associated with the given scheduler role.
|scheduler_role| is the name of the role which is passed when creating dispatchers.
Sourcepub fn set_thread_limit(
&self,
scheduler_role: &str,
max_threads: u32,
) -> Result<(), Status>
pub fn set_thread_limit( &self, scheduler_role: &str, max_threads: u32, ) -> Result<(), Status>
Sets the number of threads which will be spawned for thread pool associated with the given scheduler role. It cannot shrink the limit less to a value lower than the current number of threads in the thread pool.
|scheduler_role| is the name of the role which is passed when creating dispatchers. |max_threads| is the number of threads to use as new limit.