GraphLab: Distributed Graph-Parallel API
2.1
|
#include <graphlab/util/safe_circular_char_buffer.hpp>
Public Member Functions | |
safe_circular_char_buffer (std::streamsize bufsize=10485760) | |
void | stop_reader () |
bool | empty () const |
bool | is_done () const |
bool | reader_is_blocked () const |
std::streamsize | size () const |
std::streamsize | free_space () const |
std::streamsize | reserved_size () const |
std::streamsize | write (const char *c, std::streamsize clen) |
std::streamsize | write_unsafe (const char *c, std::streamsize clen) |
std::streamsize | introspective_read (char *&s, std::streamsize clen) |
std::streamsize | blocking_introspective_read (char *&s, std::streamsize clen) |
void | advance_head (const std::streamsize advance_len) |
void | begin_critical_section () |
void | end_critical_section () |
void | end_critical_section_with_signal () |
A non-resizing circular char buffer with thread-safe write operations and a single reader
Definition at line 37 of file safe_circular_char_buffer.hpp.
|
inline |
When begin critical section returns, it is guaranteed that no other writer will be touching the tail of the queue
Definition at line 124 of file safe_circular_char_buffer.hpp.
std::streamsize graphlab::safe_circular_char_buffer::blocking_introspective_read | ( | char *& | s, |
std::streamsize | clen | ||
) |
Same as introspective read. But blocks until there is something to read This function does not acquire a critical section.
Definition at line 136 of file safe_circular_char_buffer.cpp.
bool graphlab::safe_circular_char_buffer::empty | ( | ) | const |
Determine if the buffer is empty
Definition at line 48 of file safe_circular_char_buffer.cpp.
|
inline |
Releases a critical section acquired by begin_critical_section
Definition at line 129 of file safe_circular_char_buffer.hpp.
|
inline |
Releases a critical section acquired by begin_critical_section, and signals the reader to begin reading if the reader is blocked
Definition at line 135 of file safe_circular_char_buffer.hpp.
std::streamsize graphlab::safe_circular_char_buffer::free_space | ( | ) | const |
Get the amount of free space reamining in the buffer
Definition at line 60 of file safe_circular_char_buffer.cpp.
std::streamsize graphlab::safe_circular_char_buffer::introspective_read | ( | char *& | s, |
std::streamsize | clen | ||
) |
Returns a pointer (through s) and a length of the read. This pointer is a direct pointer into the internal buffer of this datastructure. The pointer is valid as long as no other operations are performed on this structure. The length of the introspective_read may be less than the number of bytes requested. Multiple calls to introspective_read may be necessary to read all data in the buffer. If the function returns 0, the buffer is empty.
No locks are acquired on this call.
Definition at line 109 of file safe_circular_char_buffer.cpp.
|
inline |
Gets the size of the buffer.
Definition at line 73 of file safe_circular_char_buffer.hpp.
std::streamsize graphlab::safe_circular_char_buffer::size | ( | ) | const |
Get the total contents currently stored in the buffer.
Definition at line 52 of file safe_circular_char_buffer.cpp.
void graphlab::safe_circular_char_buffer::stop_reader | ( | ) |
Stops the buffer and signals any blocking calls.
Definition at line 40 of file safe_circular_char_buffer.cpp.
std::streamsize graphlab::safe_circular_char_buffer::write | ( | const char * | c, |
std::streamsize | clen | ||
) |
Returns 0 if the write doesn't fit
This function acquires the critical section to perform the write
Definition at line 65 of file safe_circular_char_buffer.cpp.
std::streamsize graphlab::safe_circular_char_buffer::write_unsafe | ( | const char * | c, |
std::streamsize | clen | ||
) |
Returns 0 if the write doesn't fit
This does the same as write(), but does not acquire the critical section. The caller should ensure safety
Definition at line 76 of file safe_circular_char_buffer.cpp.