|
cgv
|
queued thread class that manages a named pipe More...
#include <pipe_thread.h>
Public Member Functions | |
| named_pipe_output_thread (const std::string &_pipe_name, bool is_binary=true, unsigned _ms_to_wait=20) | |
| construct pipe output thread from pipe name, whether to use binary mode and wait time in ms used when queue is empty | |
| std::string | get_pipe_path () const |
| return path of pipe that can be used in command line arguments to child/client processes | |
Public Member Functions inherited from cgv::os::queued_output_thread | |
| queued_output_thread (bool is_binary=true, unsigned _ms_to_wait=20) | |
| construct queued output thread from flag, whether to use binary mode and wait time in ms used when queue is empty | |
| void | run () |
connect to child process and continuously write queue content to pipe; if empty wait in intervals of ms_to_wait miliseconds or close pipe and terminate if done() had been called | |
| bool | has_connection () const |
| returns true as soon as child process has connected to pipe | |
| bool | send_block (const char *data, size_t count) |
| if done() had not been called, insert a data block into the queue; can fail if done() or out of memory | |
| size_t | get_nr_blocks () const |
| returns the number of blocks in the queue of not yet written data | |
| size_t | get_nr_bytes () const |
| returns the number of bytes in the queue of not yet written data, what is more time consuming than get_nr_blocks() | |
| void | done () |
| call this to announce the all data has been sent | |
Public Member Functions inherited from cgv::os::thread | |
| 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_child_process () |
| creates pipe and waits for connection | |
| void | write_block_to_pipe (const char *data, size_t count) |
| write block to named pipe | |
| void | close () |
| closes named pipe | |
Protected Member Functions inherited from cgv::os::thread | |
| void | execute () |
| executes the run method | |
Protected Attributes | |
| std::string | pipe_name |
| based name of the | |
| nes::basic_pipe_ostream< char, std::char_traits< char > > * | pipe_ptr = 0 |
| pointer to the named pipe output stream | |
Protected Attributes inherited from cgv::os::queued_output_thread | |
| bool | is_binary |
| whether binary mode should be used | |
| bool | connected = false |
| flag that tells whether the pipe has been connected to from the other side | |
| cgv::os::mutex | m |
mutex used to protect access to blocks | |
| std::deque< std::pair< char *, size_t > > | blocks |
| deque used to queue the data blocks that should be written to the pipe by the thread | |
| unsigned | ms_to_wait |
| time in miliseconds to wait while queue is empty | |
Protected Attributes inherited from cgv::os::thread | |
| void * | thread_ptr |
| bool | stop_request |
| bool | running |
| bool | delete_after_termination |
Additional Inherited Members | |
Static Public Member Functions inherited from cgv::os::thread | |
| 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 Protected Member Functions inherited from cgv::os::thread | |
| static void * | execute_s (void *args) |
queued thread class that manages a named pipe
Definition at line 59 of file pipe_thread.h.
| cgv::os::named_pipe_output_thread::named_pipe_output_thread | ( | const std::string & | _pipe_name, |
| bool | is_binary = true, |
||
| unsigned | _ms_to_wait = 20 |
||
| ) |
construct pipe output thread from pipe name, whether to use binary mode and wait time in ms used when queue is empty
Definition at line 108 of file pipe_thread.cxx.
References pipe_name.
|
protectedvirtual |
closes named pipe
Implements cgv::os::queued_output_thread.
Definition at line 132 of file pipe_thread.cxx.
References pipe_ptr.
|
protectedvirtual |
creates pipe and waits for connection
Implements cgv::os::queued_output_thread.
Definition at line 117 of file pipe_thread.cxx.
References cgv::os::queued_output_thread::is_binary, pipe_name, and pipe_ptr.
| std::string cgv::os::named_pipe_output_thread::get_pipe_path | ( | ) | const |
return path of pipe that can be used in command line arguments to child/client processes
Definition at line 113 of file pipe_thread.cxx.
References pipe_name.
|
protectedvirtual |
write block to named pipe
Implements cgv::os::queued_output_thread.
Definition at line 128 of file pipe_thread.cxx.
References pipe_ptr.
|
protected |
based name of the
Definition at line 63 of file pipe_thread.h.
Referenced by connect_to_child_process(), get_pipe_path(), and named_pipe_output_thread().
|
protected |
pointer to the named pipe output stream
Definition at line 65 of file pipe_thread.h.
Referenced by close(), connect_to_child_process(), and write_block_to_pipe().