aboutsummaryrefslogtreecommitdiffstats
path: root/man/rb_discard.3
blob: acf8f206edce1c2945f92a316d8e6e2d2a4486d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
.TH "rb_discard" "3" " 5 February 2018 (v3.0.0)" "bofc.pl"
.SH
.PP
.B rb_discard
- allows to quickly discard part of buffer
.SH SYNOPSIS
.PP
.BI "int rb_discard(struct rb *" rb ", size_t " count ");"
.SH DESCRIPTION
.PP
Function
.BR rb_discard(3)
will remove
.I count
elements from
.I rb
buffer.
This functions is very similar to calling
.BR rb_read (3)
and then discarding buffer, but this function is much better because when
discarding with
.BR rb_discard (3)
there is no copying involved, so it's much faster.
You can pass more
.I count
then there is in the buffer.
Function never blocks calling thread.
.PP
Note, it is very difficult to discard data in multi-threaded environment with
more than one reader per se.
Thus it is inadvisible to use this function when there are two or more readers
using same
.I rb
object.
.SH RETURN VALUES
.PP
Function will return number of elements actually discarded fomr buffer. It is
ok for function to return less elements than it was passed in
.I count
variable.
This means there was less elements in
.I rb
than requested to be discarded.
On errors -1 is returned.
.SH ERRORS
.PP
.TP
.B EINVAL
.I rb
is not a valid object.
.SH SEE ALSO
.PP
.BR rb_overview (7),
.BR rb_new (3),
.BR rb_destroy (3),
.BR rb_stop (3),
.BR rb_read (3),
.BR rb_recv (3),
.BR rb_write (3),
.BR rb_send (3),
.BR rb_clear (3),
.BR rb_count (3),
.BR rb_space (3),
.BR rb_version (3)