[][src]Struct async_logger::AsyncLoggerNB

pub struct AsyncLoggerNB { /* fields omitted */ }

Logger with non-blocking async processing.

Methods

impl AsyncLoggerNB[src]

pub fn new(
    writer: Box<dyn Writer>,
    buf_sz: usize
) -> Result<AsyncLoggerNB, Error>
[src]

Create a new AsyncLoggerNB instance with buffer of buf_size.

Errors

Err is returend if buf_sz is greater than std::isize::MAX or buf_sz is zero, or if memory allocation has failed for some reason (e.g. OOM).

Panics

Panics of OS fails to create thread.

pub fn terminate(self)[src]

Flush underlying buffers, and wait until writer thread terminates. Further attempts to write to buffers will return error.

Panics

Panics if some of the internal mutexes is poisoned, or when writer thread paniced.

pub fn write_slice(&self, slice: &[u8]) -> Result<(), ()>[src]

Write a slice of u8. If the size of slice is larger or equal to 0.8 * buffer_size then buffer is bypassed, and slice is handed directly to writer. Note, in this case message can appear out-of-order. Function blocks if message size is less than 0.8 * buffer_size, and there is not enough free space in any of buffers. As soon as there is free space larger than 0.8 * buffer_size available slice is written and function returns.

Errors

Err is returned when the function tries to put slice in buffer after terminate was called. This is normally not expected, because terminate takes ownership on logger instance.

Panics

This function panics if some of the internal mutexes is poisoned or when writer panics.

pub fn flush(&self)[src]

Mark not yet full buffer as ready for writer. This function doesn't call `Writer::flush. This function doesn't wait while writer process all the previously written data.

Panics

Panics if some of the internal mutexes is poisoned.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.