diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2018-02-01 07:45:10 +0100 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2018-02-01 07:45:10 +0100 |
commit | e5ebd7911e3f6aebc780fbb75bfe478eae663b67 (patch) | |
tree | 4022b5cbdc49fd689d7f9bcfef3bc6ebd044dbf9 | |
parent | eb64f0acfce4102b6af59916c7f1d3372c1ef7b0 (diff) | |
download | librb-e5ebd7911e3f6aebc780fbb75bfe478eae663b67.tar.gz librb-e5ebd7911e3f6aebc780fbb75bfe478eae663b67.tar.bz2 librb-e5ebd7911e3f6aebc780fbb75bfe478eae663b67.zip |
update documentation
-rw-r--r-- | man/rb_new.3 | 50 | ||||
-rw-r--r-- | man/rb_overview.7 | 32 |
2 files changed, 34 insertions, 48 deletions
diff --git a/man/rb_new.3 b/man/rb_new.3 index 19c5c04..2dc945d 100644 --- a/man/rb_new.3 +++ b/man/rb_new.3 @@ -59,43 +59,21 @@ Proper functions will then return with errno set to .B EAGAIN and number of elements actually commited. This is default behaviour when +.B O_MULTITHREAD +flag was +.B not +passed and .B librb -is compiler without -.BR ENABLE_THREADS. +is working in single thread mode. .TP -.B O_NONTHREAD +.B O_MULTITHREAD this can be set only when library has been compiled with -.B ENABLE_THREADS -otherwise, this flag is ignored. If set, +.BR ENABLE_THREADS , +otherwise error will be returned. If set, .B librb -functions will not be using pthread. -This should be used only when you are sure that +functions will be using pthreads to provide synchronization of threads accessing .I rb -object will be accessed at most by 1 thread at a time. -If more than 1 thread will try access -.I rb -object when this flag is set, such call will result in undefined behaviour. -When -.B O_NONTHREAD -is set, -.B O_NONBLOCK -should also be set so -all function calls are non-blocking. -If -.B ENABLE_THREADS -is not set, funcions -behave as ( -.B O_NONTHREAD -| -.BR O_NONBLOCK ) -flag was set. -When this flag is passed to -.BR rb_new (3), -user should also set -.B O_NONBLOCK -or -.B EINVAL -error will be returned to prevent deadlocks. +object. .SH RETURN VALUES .PP If no errors have been detected, function will return pointer to newly created @@ -106,11 +84,11 @@ ring buffer, otherwise NULL is returned. .I count is not a power of two number (like 4, 64, 1024). .TP -.B EINVAL -.B O_NONTHREAD +.B ENOSYS +.B O_MULTITHREAD was set but -.B O_NONBLOCK -was not (only when library was compiled with pthread support. +.B librb +was not compiled with pthread support. .TP .B ENOMEM couldn't allocate memory for given diff --git a/man/rb_overview.7 b/man/rb_overview.7 index 2d8f6fc..2469616 100644 --- a/man/rb_overview.7 +++ b/man/rb_overview.7 @@ -42,19 +42,27 @@ size_t " count ", unsigned long " flags ");" .SH DESCRIPTION .PP .B librb -is thread safe and thread aware. -If there are no resources available while reading or writting, caller thread -gets locked and doesn't use any resources until data is available. -Ring buffer can also be configured to work in non-blocking mode, so calls from +is a simple ring buffer implementation that operates on objects rather than +raw bytes. +See +.BR rb_new (3) +to know what that means. +By default library operates in single-thread mode which is way faster than +multi-thread mode but naturally will break if concurrent thread will try to +access +.I rb +object. +To relief user from pesky synchronization process, library can optionally be +thread safe and thread aware by passing +.B O_MULTITHREAD +flag to +.BR rb_new (3). +In multi-thread mode if there are no resources available while reading or +writting, caller thread gets locked and doesn't use any resources until data is +available. +This behaviour can be altered to work in non-blocking mode, so calls from read and write will return immediately when there are not enough resources. malloc and free are called only in new and destory functions. -Thread awarness can be disabled via -.B O_NONTHREAD -flags passed to -.BR rb_new (3). -In such case all calls to rb function will be non blocking. -Library can also be compiled without thread support at all, then it can be used -even in very constrained platforms. .PP As this library is focused on speed, user can create buffer with only power of two count (n^2). @@ -80,7 +88,7 @@ Please note, that example is missing error handling for simplicity. struct rb *rb; /* initialize ring buffer with 32 1-byte elements */ - rb = rb_new(32, 1, O_NONBLOCK | O_NONTHREAD); + rb = rb_new(32, 1, 0); /* add data to buffer one byte at a time */ for (i = '0'; i <= '9'; ++i) |