|
BDE 4.14.0 Production release
|
#include <balb_pipecontrolchannel.h>
Public Types | |
| typedef bsl::function< void(const bslstl::StringRef &message)> | ControlCallback |
Public Member Functions | |
| PipeControlChannel (const ControlCallback &callback, bslma::Allocator *basicAllocator=0) | |
| ~PipeControlChannel () | |
| int | start (const char *pipeName) |
| template<class STRING_TYPE > | |
| int | start (const STRING_TYPE &pipeName) |
| int | start (const char *pipeName, const bslmt::ThreadAttributes &attributes) |
| template<class STRING_TYPE > | |
| int | start (const STRING_TYPE &pipeName, const bslmt::ThreadAttributes &attributes) |
| void | shutdown () |
| void | stop () |
| const bsl::string & | pipeName () const |
| Return the fully qualified system name of the pipe. | |
| bslma::Allocator * | allocator () const |
This class is a mechanism for reading control messages from a named pipe. Use start to spawn a thread that handles messages arriving at the pipe, and shutdown to stop reading. stop blocks until the processing thread has been terminated by a call to shutdown (either before stop is called, or from some other thread).
| typedef bsl::function<void(const bslstl::StringRef& message)> balb::PipeControlChannel::ControlCallback |
This type of function is called to handle control messages received on the pipe. The message is one complete message read from the pipe, without the terminating newline character.
|
explicit |
Create a pipe control mechanism that dispatches messages to the specified callback. Optionally specify basicAllocator to supply memory. If basicAllocator is zero, the currently installed default allocator is used.
| balb::PipeControlChannel::~PipeControlChannel | ( | ) |
Destroy this object. Shut down the processing thread if it is still running and block until it terminates. Close the named pipe and clean up any associated system resources.
|
inline |
Return the allocator used by this object to supply memory. Note that if no allocator was supplied at construction the default allocator in effect at construction is used.
|
inline |
| void balb::PipeControlChannel::shutdown | ( | ) |
Stop reading from the pipe and dispatching messages. If the background thread has begun processing a message, this method will block until a message that is currently being processed completes.
| int balb::PipeControlChannel::start | ( | const char * | pipeName | ) |
Open a named pipe having the specified pipeName, and start a thread to read messages and dispatch them to the callback specified at construction. Optionally specify attributes of the background processing thread. If attributes is not supplied, a default constructed ThreadAttributes object will be used. Return 0 on success, and a non-zero value otherwise. In particular, return a non-zero value if the pipe cannot be opened or if it is detected that another process is reading from the pipe. pipeName must be of the types const char *, char *, bsl::string, std::string, std::pmr::string (if supported), or bslstl::StringRef.
| int balb::PipeControlChannel::start | ( | const char * | pipeName, |
| const bslmt::ThreadAttributes & | attributes | ||
| ) |
| int balb::PipeControlChannel::start | ( | const STRING_TYPE & | pipeName | ) |
| int balb::PipeControlChannel::start | ( | const STRING_TYPE & | pipeName, |
| const bslmt::ThreadAttributes & | attributes | ||
| ) |
| void balb::PipeControlChannel::stop | ( | ) |
Block until the background thread has been terminated by a call to shutdown. Then close the pipe and clean up the associated file.
| void* balb::PipeControlChannel::d_handle |
| int balb::PipeControlChannel::d_readFd |
| struct { ... } balb::PipeControlChannel::d_unix |
| struct { ... } balb::PipeControlChannel::d_windows |
| int balb::PipeControlChannel::d_writeFd |