pub struct Base { /* private fields */ }
Expand description
Wrapper for libevent’s event_base
which is responsible for executing
associated events.
Implementations§
Source§impl Base
The handle that abstracts over libevent’s API in Rust.
impl Base
The handle that abstracts over libevent’s API in Rust.
Sourcepub unsafe fn from_raw(base: NonNull<event_base>) -> Self
pub unsafe fn from_raw(base: NonNull<event_base>) -> Self
Creates a new instance of Base
using a raw, non-null event_base
pointer.
§Safety
This function expects a non-null pointer, and thus does no such checks
internally. Thus the caller is responsible for checking the
event_base
validity.
Sourcepub unsafe fn as_raw(&self) -> NonNull<event_base>
pub unsafe fn as_raw(&self) -> NonNull<event_base>
Exposes the raw, non-null event_base
pointer.
§Safety
This function returns a valid, non-null event_base
pointer which by
itself is safe. However, this function serves as an escape hatch to do
unsafe things.
Sourcepub fn loop_(&self, flags: LoopFlags) -> ExitReason
pub fn loop_(&self, flags: LoopFlags) -> ExitReason
Wrapper for libevent’s event_base_loop
, which runs the event loop in
a manner defined by the LoopFlags
input.
Sourcepub fn loopexit(&self, timeout: Duration) -> i32
pub fn loopexit(&self, timeout: Duration) -> i32
Wrapper for libevent’s event_base_loopexit
, which tells the running
event loop to exit after a specified Duration
.
Sourcepub fn loopbreak(&self) -> i32
pub fn loopbreak(&self) -> i32
Wrapper for libevent’s event_base_loopbreak
, which tells the running
event loop to break immediately.
Sourcepub fn loopcontinue(&self) -> i32
pub fn loopcontinue(&self) -> i32
Wrapper for libevent’s event_base_loopcontinue
, which tells the
running event loop to resume searching for active events.
Sourcepub fn event_new(
&mut self,
fd: Option<EvutilSocket>,
flags: EventFlags,
callback: extern "C" fn(EvutilSocket, EventCallbackFlags, EventCallbackCtx),
callback_ctx: Option<EventCallbackCtx>,
) -> Option<NonNull<event>>
pub fn event_new( &mut self, fd: Option<EvutilSocket>, flags: EventFlags, callback: extern "C" fn(EvutilSocket, EventCallbackFlags, EventCallbackCtx), callback_ctx: Option<EventCallbackCtx>, ) -> Option<NonNull<event>>
Wrapper for libevent’s event_new
, which allocates and initializes a
new event
with the given parameters.
Sourcepub fn event_assign(
&mut self,
ev: NonNull<event>,
fd: Option<EvutilSocket>,
flags: EventFlags,
callback: extern "C" fn(EvutilSocket, EventCallbackFlags, EventCallbackCtx),
callback_ctx: Option<EventCallbackCtx>,
) -> c_int
pub fn event_assign( &mut self, ev: NonNull<event>, fd: Option<EvutilSocket>, flags: EventFlags, callback: extern "C" fn(EvutilSocket, EventCallbackFlags, EventCallbackCtx), callback_ctx: Option<EventCallbackCtx>, ) -> c_int
Wrapper for libevent’s event_new
, which initializes a pre-allocated
event
with the given parameters.
Source§impl Base
impl Base
Sourcepub fn spawn<T: Exec<Internal<T>, F>, F>(
&mut self,
ev: Event<Inactive<T>>,
cb: F,
) -> Result<()>
pub fn spawn<T: Exec<Internal<T>, F>, F>( &mut self, ev: Event<Inactive<T>>, cb: F, ) -> Result<()>
Activates a given inactive Event
with no handle sharing.
Control of the event via the Event
handle is relegated only from
within the closure F
, which means that no synchronization wrappers
are required for operation.
Sourcepub fn spawn_local<T: Exec<LocalWeak<T>, F>, F>(
&mut self,
ev: Event<Inactive<T>>,
cb: F,
) -> Result<Event<Local<T>>>
pub fn spawn_local<T: Exec<LocalWeak<T>, F>, F>( &mut self, ev: Event<Inactive<T>>, cb: F, ) -> Result<Event<Local<T>>>
Activates a given inactive Event
with thread-local sharing.
Control of the event via the Event
handle is shared between the
closure F
as well as the returned Event
, which internally uses an
Rc<RefCell>
.
Source§impl Base
impl Base
Sourcepub fn turn(&self) -> ExitReason
pub fn turn(&self) -> ExitReason
Turns the libevent base once.
Sourcepub fn run_timeout(&self, timeout: Duration) -> ExitReason
pub fn run_timeout(&self, timeout: Duration) -> ExitReason
Turns the libevent base until exit or timeout duration reached.
Sourcepub fn run_until_event(&self, timeout: Option<Duration>) -> ExitReason
pub fn run_until_event(&self, timeout: Option<Duration>) -> ExitReason
Turns the libevent base until next active event.
Sourcepub fn run(&self) -> ExitReason
pub fn run(&self) -> ExitReason
Turns the libevent base until exit.