[−][src]Struct node_replication::Log
A log of operations that is typically accessed by multiple Replica.
Operations can be added to the log by calling the append()
method and
providing a list of operations to be performed.
Operations already on the log can be executed by calling the exec()
method
and providing a replica-id along with a closure. Newly added operations
since the replica last called exec()
will be executed by invoking the
supplied closure for each one of them.
Accepts one generic type parameter; T
defines the type of operations and
their arguments that will go on the log and would typically be an enum
class.
This struct is aligned to 64 bytes optimizing cache access.
Note
As a client, typically there is no need to call any methods on the Log aside
from new
. Only in the rare circumstance someone would implement their own
Replica would it be necessary to call any of the Log's methods.
Implementations
impl<'a, T> Log<'a, T> where
T: Sized + Clone,
[src]
T: Sized + Clone,
pub fn new<'b>(bytes: usize) -> Log<'b, T>
[src]
Constructs and returns a log of size bytes
bytes.
A size between 1-2 MiB usually works well in most cases.
Example
use node_replication::Log; // Operation type that will go onto the log. #[derive(Clone)] enum Operation { Read, Write(u64), Invalid, } // Creates a 1 Mega Byte sized log. let l = Log::<Operation>::new(1 * 1024 * 1024);
This method also allocates memory for the log upfront. No further allocations will be performed once this method returns.
Trait Implementations
impl<'a, T> Debug for Log<'a, T> where
T: Sized + Clone,
[src]
T: Sized + Clone,
impl<'a, T> Default for Log<'a, T> where
T: Sized + Clone,
[src]
T: Sized + Clone,
impl<'a, T> Drop for Log<'a, T> where
T: Sized + Clone,
[src]
T: Sized + Clone,
impl<'a, T> Send for Log<'a, T> where
T: Sized + Clone,
[src]
T: Sized + Clone,
The Log is Send. The *mut u8 (rawp
) is never dereferenced.
impl<'a, T> Sync for Log<'a, T> where
T: Sized + Clone,
[src]
T: Sized + Clone,
The Log is Sync. We know this because: head
and tail
are atomic variables, append()
reserves entries using a CAS, and exec() does not concurrently mutate entries on the log.
Auto Trait Implementations
impl<'a, T> !RefUnwindSafe for Log<'a, T>
impl<'a, T> Unpin for Log<'a, T>
impl<'a, T> !UnwindSafe for Log<'a, T>
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>,