Struct SqlInterruptHandle
pub struct SqlInterruptHandle { /* private fields */ }
Expand description
Interrupt operations that use SQL
Typical usage of this type:
- Components typically create a wrapper class around an
rusqlite::Connection
(PlacesConnection
,LoginStore
, etc.) - The wrapper stores an
Arc<SqlInterruptHandle>
- The wrapper has a method that clones and returns that
Arc
. This allows passing the interrupt handle to a different thread in order to interrupt a particular operation. - The wrapper calls
begin_interrupt_scope()
at the start of each operation. The code that performs the operation periodically callserr_if_interrupted()
. - Finally, the wrapper class implements
AsRef<SqlInterruptHandle>
and callsregister_interrupt()
. This causes all operations to be interrupted when we enter shutdown mode.
Implementations§
§impl SqlInterruptHandle
impl SqlInterruptHandle
pub fn new(conn: &Connection) -> SqlInterruptHandle
pub fn begin_interrupt_scope(&self) -> Result<SqlInterruptScope, Interrupted>
pub fn begin_interrupt_scope(&self) -> Result<SqlInterruptScope, Interrupted>
Begin an interrupt scope that will be interrupted by this handle
Returns Err(Interrupted) if we’re in shutdown mode
pub fn interrupt(&self)
pub fn interrupt(&self)
Interrupt all interrupt scopes created by this handle
Trait Implementations§
source§impl AsRef<SqlInterruptHandle> for PlacesConnection
impl AsRef<SqlInterruptHandle> for PlacesConnection
source§fn as_ref(&self) -> &SqlInterruptHandle
fn as_ref(&self) -> &SqlInterruptHandle
Converts this type into a shared reference of the (usually inferred) input type.
source§fn as_ref(&self) -> &SqlInterruptHandle
fn as_ref(&self) -> &SqlInterruptHandle
Converts this type into a shared reference of the (usually inferred) input type.
§impl AsRef<SqlInterruptHandle> for SqlInterruptHandle
impl AsRef<SqlInterruptHandle> for SqlInterruptHandle
§fn as_ref(&self) -> &SqlInterruptHandle
fn as_ref(&self) -> &SqlInterruptHandle
Converts this type into a shared reference of the (usually inferred) input type.
Auto Trait Implementations§
impl Freeze for SqlInterruptHandle
impl RefUnwindSafe for SqlInterruptHandle
impl Send for SqlInterruptHandle
impl Sync for SqlInterruptHandle
impl Unpin for SqlInterruptHandle
impl UnwindSafe for SqlInterruptHandle
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, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
Arc<>
Read more