[−][src]Struct places_ffi::CONNECTIONS
Fields
__private_field: ()
Methods from Deref<Target = ConcurrentHandleMap<PlacesDb>>
pub fn len(&self) -> usize
[src]
Get the number of entries in the ConcurrentHandleMap
.
This takes the map's read
lock.
pub fn is_empty(&self) -> bool
[src]
Returns true if the ConcurrentHandleMap
is empty.
This takes the map's read
lock.
pub fn insert(&self, v: T) -> Handle
[src]
Insert an item into the map, returning the newly allocated handle to the item.
Locking
Note that this requires taking the map's write lock, and so it will block until all other threads have finished any read/write operations.
pub fn delete(&self, h: Handle) -> Result<(), HandleError>
[src]
Remove an item from the map.
Locking
Note that this requires taking the map's write lock, and so it will block until all other threads have finished any read/write operations.
pub fn delete_u64(&self, h: u64) -> Result<(), HandleError>
[src]
Convenient wrapper for delete
which takes a u64
that it will
convert to a handle.
The main benefit (besides convenience) of this over the version
that takes a [Handle
] is that it allows handling handle-related errors
in one place.
pub fn remove(&self, h: Handle) -> Result<Option<T>, HandleError>
[src]
Remove an item from the map, returning either the item, or None if its guard mutex got poisoned at some point.
Locking
Note that this requires taking the map's write lock, and so it will block until all other threads have finished any read/write operations.
pub fn remove_u64(&self, h: u64) -> Result<Option<T>, HandleError>
[src]
Convenient wrapper for remove
which takes a u64
that it will
convert to a handle.
The main benefit (besides convenience) of this over the version
that takes a [Handle
] is that it allows handling handle-related errors
in one place.
pub fn get<F, E, R>(&self, h: Handle, callback: F) -> Result<R, E> where
E: From<HandleError>,
F: FnOnce(&T) -> Result<R, E>,
[src]
E: From<HandleError>,
F: FnOnce(&T) -> Result<R, E>,
Call callback
with a non-mutable reference to the item from the map,
after acquiring the necessary locks.
Locking
Note that this requires taking both:
- The map's read lock, and so it will block until all other threads have finished any write operations.
- The mutex on the slot the handle is mapped to.
And so it will block if there are ongoing write operations, or if another thread is reading from the same handle.
Panics
This will panic if a previous get()
or get_mut()
call has panicked
inside it's callback. The solution to this
(It may also panic if the handle map detects internal state corruption, however this should not happen except for bugs in the handle map code).
pub fn get_mut<F, E, R>(&self, h: Handle, callback: F) -> Result<R, E> where
E: From<HandleError>,
F: FnOnce(&mut T) -> Result<R, E>,
[src]
E: From<HandleError>,
F: FnOnce(&mut T) -> Result<R, E>,
Call callback
with a mutable reference to the item from the map, after
acquiring the necessary locks.
Locking
Note that this requires taking both:
- The map's read lock, and so it will block until all other threads have finished any write operations.
- The mutex on the slot the handle is mapped to.
And so it will block if there are ongoing write operations, or if another thread is reading from the same handle.
Panics
This will panic if a previous get()
or get_mut()
call has panicked
inside it's callback. The only solution to this is to remove and reinsert
said item.
(It may also panic if the handle map detects internal state corruption, however this should not happen except for bugs in the handle map code).
pub fn get_u64<F, E, R>(&self, u: u64, callback: F) -> Result<R, E> where
E: From<HandleError>,
F: FnOnce(&T) -> Result<R, E>,
[src]
E: From<HandleError>,
F: FnOnce(&T) -> Result<R, E>,
Convenient wrapper for get
which takes a u64
that it will convert to
a handle.
The other benefit (besides convenience) of this over the version
that takes a [Handle
] is that it allows handling handle-related errors
in one place.
Locking
Note that this requires taking both:
- The map's read lock, and so it will block until all other threads have finished any write operations.
- The mutex on the slot the handle is mapped to.
And so it will block if there are ongoing write operations, or if another thread is reading from the same handle.
pub fn get_mut_u64<F, E, R>(&self, u: u64, callback: F) -> Result<R, E> where
E: From<HandleError>,
F: FnOnce(&mut T) -> Result<R, E>,
[src]
E: From<HandleError>,
F: FnOnce(&mut T) -> Result<R, E>,
Convenient wrapper for get_mut
which takes a u64
that it will
convert to a handle.
The main benefit (besides convenience) of this over the version
that takes a [Handle
] is that it allows handling handle-related errors
in one place.
Locking
Note that this requires taking both:
- The map's read lock, and so it will block until all other threads have finished any write operations.
- The mutex on the slot the handle is mapped to.
And so it will block if there are ongoing write operations, or if another thread is reading from the same handle.
pub fn call_with_result_mut<R, E, F>(
&self,
out_error: &mut ExternError,
h: u64,
callback: F
) -> <R as IntoFfi>::Value where
F: UnwindSafe + FnOnce(&mut T) -> Result<R, E>,
R: IntoFfi,
ExternError: From<E>,
[src]
&self,
out_error: &mut ExternError,
h: u64,
callback: F
) -> <R as IntoFfi>::Value where
F: UnwindSafe + FnOnce(&mut T) -> Result<R, E>,
R: IntoFfi,
ExternError: From<E>,
Helper that performs both a [call_with_result
] and get
.
pub fn call_with_result<R, E, F>(
&self,
out_error: &mut ExternError,
h: u64,
callback: F
) -> <R as IntoFfi>::Value where
F: UnwindSafe + FnOnce(&T) -> Result<R, E>,
R: IntoFfi,
ExternError: From<E>,
[src]
&self,
out_error: &mut ExternError,
h: u64,
callback: F
) -> <R as IntoFfi>::Value where
F: UnwindSafe + FnOnce(&T) -> Result<R, E>,
R: IntoFfi,
ExternError: From<E>,
Helper that performs both a [call_with_result
] and get
.
pub fn call_with_output<R, F>(
&self,
out_error: &mut ExternError,
h: u64,
callback: F
) -> <R as IntoFfi>::Value where
F: UnwindSafe + FnOnce(&T) -> R,
R: IntoFfi,
[src]
&self,
out_error: &mut ExternError,
h: u64,
callback: F
) -> <R as IntoFfi>::Value where
F: UnwindSafe + FnOnce(&T) -> R,
R: IntoFfi,
Helper that performs both a [call_with_output
] and get
.
pub fn call_with_output_mut<R, F>(
&self,
out_error: &mut ExternError,
h: u64,
callback: F
) -> <R as IntoFfi>::Value where
F: UnwindSafe + FnOnce(&mut T) -> R,
R: IntoFfi,
[src]
&self,
out_error: &mut ExternError,
h: u64,
callback: F
) -> <R as IntoFfi>::Value where
F: UnwindSafe + FnOnce(&mut T) -> R,
R: IntoFfi,
Helper that performs both a [call_with_output
] and get_mut
.
pub fn insert_with_result<E, F>(
&self,
out_error: &mut ExternError,
constructor: F
) -> u64 where
F: UnwindSafe + FnOnce() -> Result<T, E>,
ExternError: From<E>,
[src]
&self,
out_error: &mut ExternError,
constructor: F
) -> u64 where
F: UnwindSafe + FnOnce() -> Result<T, E>,
ExternError: From<E>,
Use constructor
to create and insert a T
, while inside a
[call_with_result
] call (to handle panics and map errors onto an
ExternError
).
pub fn insert_with_output<F>(
&self,
out_error: &mut ExternError,
constructor: F
) -> u64 where
F: UnwindSafe + FnOnce() -> T,
[src]
&self,
out_error: &mut ExternError,
constructor: F
) -> u64 where
F: UnwindSafe + FnOnce() -> T,
Equivalent to
insert_with_result
for the
case where the constructor cannot produce an error.
The name is somewhat dubious, since there's no output
, but it's intended to make it
clear that it contains a [call_with_output
] internally.
Trait Implementations
impl Deref for CONNECTIONS
[src]
type Target = ConcurrentHandleMap<PlacesDb>
The resulting type after dereferencing.
fn deref(&self) -> &ConcurrentHandleMap<PlacesDb>
[src]
impl LazyStatic for CONNECTIONS
[src]
fn initialize(lazy: &Self)
[src]
Auto Trait Implementations
impl RefUnwindSafe for CONNECTIONS
impl Send for CONNECTIONS
impl Sync for CONNECTIONS
impl Unpin for CONNECTIONS
impl UnwindSafe for CONNECTIONS
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,
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, 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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,