pub struct RwBuffer(/* private fields */);
Expand description
A base instance which holds the leaked
pointer to RwBufferInner.
This instance can provide either an exclusive write access or multiple read access, but not at the same time. Can be used to store the instance. This instance is Send and Sync because the insternals are guarded by ordered atomic operations.
Implementations§
Source§impl RwBuffer
impl RwBuffer
Sourcepub fn is_free(&self) -> bool
pub fn is_free(&self) -> bool
Checks if this instance satisfies the following conditions:
-
No exclusive write access
-
No read access
-
There is only one base reference.
§Returns
-
true
if instance satisfies the conditions above.
-
false
if does not satisfy the conditions above.
Sourcepub fn accure_if_free(&self) -> bool
pub fn accure_if_free(&self) -> bool
Accures the instance, if it satisfy the following conditions:
-
No exclusive write access
-
No read access
-
There is only one base reference.
§Returns
-
true
if instance satisfies the conditions above.
-
false
if does not satisfy the conditions above.
Sourcepub fn write(&self) -> RwBufferRes<WBuffer>
pub fn write(&self) -> RwBufferRes<WBuffer>
Attemts to make an exclusive (write) access to the buffer.
§Returns
A Result in form of RwBufferRes is returned with:
-
Result::Ok with the WBuffer instance
-
Result::Err may be returned a RwBufferError::WriteTryAgianLater in case if the there is/are an active
read
references.
Sourcepub fn read(&self) -> RwBufferRes<RBuffer>
pub fn read(&self) -> RwBufferRes<RBuffer>
Attemts to make a shared (read) access to the buffer.
§Returns
A Result in form of RwBufferRes is returned with:
-
Result::Ok with the RBuffer instance
-
Result::Err with error type is returned:
-
RwBufferError::TooManyRead is returned when the soft limit of references was reached.
-
RwBufferError::ReadTryAgianLater is returned if there is an active exclusive access.