[−][src]Struct glommio::LocalExecutorBuilder
LocalExecutor factory, which can be used in order to configure the properties of a new
LocalExecutor
.
Methods can be chained on it in order to configure it.
The spawn
method will take ownership of the builder and create an
io::Result
to the LocalExecutor
handle with the given configuration.
The LocalExecutor::make_default
free function uses a Builder with default configuration and
unwraps its return value.
You may want to use LocalExecutorBuilder::spawn
instead of LocalExecutor::make_default
,
when you want to recover from a failure to launch a thread, indeed the free function will panic
where the Builder method will return a io::Result
.
Examples
use glommio::LocalExecutorBuilder; let builder = LocalExecutorBuilder::new(); let ex = builder.make().unwrap();
Implementations
impl LocalExecutorBuilder
[src]
pub fn new() -> LocalExecutorBuilder
[src]
Generates the base configuration for spawning a LocalExecutor
, from which configuration
methods can be chained.
pub fn pin_to_cpu(self, cpu: usize) -> LocalExecutorBuilder
[src]
Sets the new executor's affinity to the provided CPU
pub fn spin_before_park(self, spin: Duration) -> LocalExecutorBuilder
[src]
Spin for duration before parking a reactor
pub fn name(self, name: &str) -> LocalExecutorBuilder
[src]
Names the thread-to-be. Currently the name is used for identification only in panic messages.
pub fn make(self) -> Result<LocalExecutor>
[src]
Make a new LocalExecutor
by taking ownership of the Builder, and returns an
io::Result
to the executor.
Examples
use glommio::LocalExecutorBuilder; let local_ex = LocalExecutorBuilder::new().make().unwrap();
#[must_use =
"This spawns an executor on a thread, so you must acquire its handle and then join() to keep it alive"]pub fn spawn<G, F, T>(self, fut_gen: G) -> Result<JoinHandle<()>> where
G: FnOnce() -> F + Send + 'static,
F: Future<Output = T> + 'static,
[src]
G: FnOnce() -> F + Send + 'static,
F: Future<Output = T> + 'static,
Spawns a new LocalExecutor
in a new thread by taking ownership of the Builder,
and returns an io::Result to its JoinHandle.
This is a more ergonomic way to create a thread and then run an executor inside it This function panics if creating the thread or the executor fails. If you need more fine-grained error handling consider initializing those entities manually.
Examples
use glommio::LocalExecutorBuilder; let handle = LocalExecutorBuilder::new().spawn(|| async move { println!("hello"); }).unwrap(); handle.join().unwrap();
Trait Implementations
impl Debug for LocalExecutorBuilder
[src]
impl Default for LocalExecutorBuilder
[src]
Auto Trait Implementations
impl RefUnwindSafe for LocalExecutorBuilder
impl Send for LocalExecutorBuilder
impl Sync for LocalExecutorBuilder
impl Unpin for LocalExecutorBuilder
impl UnwindSafe for LocalExecutorBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,