cgv
|
Public Member Functions | |
named_pipe_input_thread (const std::string &_pipe_name, bool is_binary, size_t _package_size, size_t _packeges_per_block, unsigned _ms_to_wait) | |
std::string | get_pipe_path () const |
![]() | |
queued_input_thread (bool _is_binary, size_t _package_size, size_t _packeges_per_block, unsigned _ms_to_wait) | |
construct queued input thread with binary mode flag and wait time in ms used when pipe is empty | |
void | run () |
continuously read from pipe and store in queue; if empty, wait in intervals of ms_to_wait milliseconds | |
bool | pop_data_block (char *buffer) |
if done() had not been called, read a data block from the queue; can fail if no data or done() was called | |
size_t | get_nr_blocks () const |
returns the number of blocks in the queue of not yet read data | |
void | done () |
call this to indicate no more data will come | |
![]() | |
thread () | |
create the thread | |
virtual | ~thread () |
standard destructor (a running thread will be killed) | |
void | start (bool _delete_after_termination=false) |
start the implemented run() method (asynchronly) and destruct the thread object | |
void | stop () |
try to stop the thread execution via indicating a stop request. | |
void | kill () |
kill a running thread | |
void | wait_for_completion () |
the thread is interpreted as a slave thread and started from another master thread. | |
bool | is_running () |
return true if thread is running | |
bool | have_stop_request () |
check if there is a stop request | |
thread_id_type | get_id () const |
return id of this thread | |
Protected Member Functions | |
bool | connect_to_source () override |
to be implemented in derived classes | |
size_t | read_package_from_pipe (char *buffer, size_t package_size) override |
to be implemented in derived classes | |
void | close () override |
to be implemented in derived classes | |
![]() | |
virtual void | move_packages_to_data_blocks () |
combine the packages to a data block and push it to the queue | |
![]() | |
void | execute () |
executes the run method | |
Protected Attributes | |
std::string | pipe_name |
nes::basic_pipe_istream< char, std::char_traits< char > > * | pipe_ptr = 0 |
![]() | |
bool | all_data_received = false |
flag to mark end of data stream | |
bool | is_binary |
whether binary mode should be used | |
size_t | package_size |
size of an indiviual package | |
size_t | package_index |
index of the next package to be read | |
size_t | packages_per_block |
amount of packeges needed to form one data block | |
std::mutex | mutex_packages |
mutex used to protect access to packages | |
std::mutex | mutex_data_blocks |
mutex used to protect access to data_blocks | |
char * | packages |
allocated memory for smaller data packages | |
std::deque< std::vector< char > > | data_blocks |
deque to store data blocks that are formed by packages | |
unsigned | ms_to_wait |
time in milliseconds to wait while pipe is empty | |
![]() | |
void * | thread_ptr |
bool | stop_request |
bool | running |
bool | delete_after_termination |
Additional Inherited Members | |
![]() | |
static void | wait_for_signal (condition_mutex &cm) |
sleep till the signal from the given condition_mutex is sent, lock the mutex first and unlock after waiting | |
static void | wait_for_signal_with_lock (condition_mutex &cm) |
prefered approach to wait for signal and implemented as { cm.lock(); wait_for_signal(cm); cm.unlock(); } | |
static bool | wait_for_signal_or_timeout (condition_mutex &cm, unsigned millisec) |
sleep till the signal from the given condition_mutex is sent or the timeout is reached, lock the mutex first and unlock after waiting | |
static bool | wait_for_signal_or_timeout_with_lock (condition_mutex &cm, unsigned millisec) |
prefered approach to wait for signal or the timeout is reached and implemented as { cm.lock(); wait_for_signal_or_timeout(cm,millisec); cm.unlock(); } | |
static void | wait (unsigned millisec) |
wait the given number of milliseconds | |
static thread_id_type | get_current_thread_id () |
return the id of the currently executed thread | |
![]() | |
static void * | execute_s (void *args) |
Definition at line 159 of file pipe_thread.h.
cgv::os::named_pipe_input_thread::named_pipe_input_thread | ( | const std::string & | _pipe_name, |
bool | is_binary, | ||
size_t | _package_size, | ||
size_t | _packeges_per_block, | ||
unsigned | _ms_to_wait | ||
) |
Definition at line 287 of file pipe_thread.cxx.
|
overrideprotectedvirtual |
to be implemented in derived classes
Implements cgv::os::queued_input_thread.
Definition at line 279 of file pipe_thread.cxx.
|
overrideprotectedvirtual |
to be implemented in derived classes
Implements cgv::os::queued_input_thread.
Definition at line 259 of file pipe_thread.cxx.
References cgv::os::queued_input_thread::is_binary.
std::string cgv::os::named_pipe_input_thread::get_pipe_path | ( | ) | const |
Definition at line 293 of file pipe_thread.cxx.
|
overrideprotectedvirtual |
to be implemented in derived classes
Implements cgv::os::queued_input_thread.
Definition at line 270 of file pipe_thread.cxx.
References cgv::os::queued_input_thread::all_data_received, cgv::os::queued_input_thread::mutex_packages, and cgv::os::queued_input_thread::package_size.
|
protected |
Definition at line 162 of file pipe_thread.h.
|
protected |
Definition at line 163 of file pipe_thread.h.