pub struct MainContext(/* private fields */);
Implementations§
Source§impl MainContext
impl MainContext
pub fn new() -> MainContext
pub fn acquire(&self) -> bool
pub fn dispatch(&self)
pub fn is_owner(&self) -> bool
pub fn iteration(&self, may_block: bool) -> bool
pub fn pending(&self) -> bool
pub fn pop_thread_default(&self)
pub fn push_thread_default(&self)
pub fn release(&self)
pub fn wakeup(&self)
pub fn default() -> MainContext
pub fn get_thread_default() -> Option<MainContext>
pub fn ref_thread_default() -> MainContext
Source§impl MainContext
impl MainContext
pub fn prepare(&self) -> (bool, i32)
pub fn find_source_by_id(&self, source_id: &SourceId) -> Option<Source>
Sourcepub fn invoke_with_priority<F>(&self, priority: Priority, func: F)
pub fn invoke_with_priority<F>(&self, priority: Priority, func: F)
Invokes func
on the main context with the given priority.
Sourcepub fn invoke_local<F>(&self, func: F)where
F: FnOnce() + 'static,
pub fn invoke_local<F>(&self, func: F)where
F: FnOnce() + 'static,
Invokes func
on the main context.
Different to invoke()
, this does not require func
to be
Send
but can only be called from the thread that owns the main context.
This function panics if called from a different thread than the one that owns the main context.
Sourcepub fn invoke_local_with_priority<F>(&self, priority: Priority, func: F)where
F: FnOnce() + 'static,
pub fn invoke_local_with_priority<F>(&self, priority: Priority, func: F)where
F: FnOnce() + 'static,
Invokes func
on the main context with the given priority.
Different to invoke_with_priority()
, this does not require func
to be
Send
but can only be called from the thread that owns the main context.
This function panics if called from a different thread than the one that owns the main context.
Sourcepub fn with_thread_default<R, F>(&self, func: F) -> R
pub fn with_thread_default<R, F>(&self, func: F) -> R
Calls closure with context configured as the thread default one.
Thread default context is changed in panic-safe manner by calling
push_thread_default
before calling closure
and pop_thread_default
afterwards regardless
of whether closure panicked or not.
Source§impl MainContext
impl MainContext
Sourcepub fn channel<T>(priority: Priority) -> (Sender<T>, Receiver<T>)
pub fn channel<T>(priority: Priority) -> (Sender<T>, Receiver<T>)
Creates a channel for a main context.
The Receiver
has to be attached to a main context at a later time, together with a
closure that will be called for every item sent to a Sender
.
The Sender
can be cloned and both the Sender
and Receiver
can be sent to different
threads as long as the item type implements the Send
trait.
When the last Sender
is dropped the channel is removed from the main context. If the
Receiver
is dropped and not attached to a main context all sending to the Sender
will fail.
The returned Sender
behaves the same as std::sync::mpsc::Sender
.
Sourcepub fn sync_channel<T>(
priority: Priority,
bound: usize,
) -> (SyncSender<T>, Receiver<T>)
pub fn sync_channel<T>( priority: Priority, bound: usize, ) -> (SyncSender<T>, Receiver<T>)
Creates a synchronous channel for a main context with a given bound on the capacity of the channel.
The Receiver
has to be attached to a main context at a later time, together with a
closure that will be called for every item sent to a SyncSender
.
The SyncSender
can be cloned and both the SyncSender
and Receiver
can be sent to different
threads as long as the item type implements the Send
trait.
When the last SyncSender
is dropped the channel is removed from the main context. If the
Receiver
is dropped and not attached to a main context all sending to the SyncSender
will fail.
The returned SyncSender
behaves the same as std::sync::mpsc::SyncSender
.
Trait Implementations§
Source§impl Clone for MainContext
impl Clone for MainContext
Source§fn clone(&self) -> MainContext
fn clone(&self) -> MainContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for MainContext
impl Debug for MainContext
Source§impl Default for MainContext
impl Default for MainContext
Source§impl Hash for MainContext
impl Hash for MainContext
Source§impl Ord for MainContext
impl Ord for MainContext
Source§fn cmp(&self, other: &MainContext) -> Ordering
fn cmp(&self, other: &MainContext) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for MainContext
impl PartialEq for MainContext
Source§impl PartialOrd for MainContext
impl PartialOrd for MainContext
Source§impl StaticType for MainContext
impl StaticType for MainContext
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for MainContext
impl Send for MainContext
impl StructuralPartialEq for MainContext
impl Sync for MainContext
Auto Trait Implementations§
impl Freeze for MainContext
impl RefUnwindSafe for MainContext
impl Unpin for MainContext
impl UnwindSafe for MainContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> ToSendValue for T
impl<T> ToSendValue for T
Source§fn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
SendValue
clone of self
.