BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balb::PipeTaskManager Class Reference

#include <balb_pipetaskmanager.h>

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (PipeTaskManager, bslma::UsesBslmaAllocator)
 
 PipeTaskManager (bslma::Allocator *basicAllocator=0)
 
 PipeTaskManager (bsl::shared_ptr< ControlManager > &controlManager, bslma::Allocator *basicAllocator=0)
 
 ~PipeTaskManager ()
 
balb::ControlManagercontrolManager ()
 
int start (const bsl::string_view &pipeBasename)
 
void shutdown ()
 
int stop ()
 
const balb::ControlManagercontrolManager () const
 
const bsl::stringpipeName () const
 
bslma::Allocatorallocator () const
 

Detailed Description

This class provides a mechanism route messages received on a named pipe to the registered handler (functor).

See balb_pipetaskmanager

Constructor & Destructor Documentation

◆ PipeTaskManager() [1/2]

balb::PipeTaskManager::PipeTaskManager ( bslma::Allocator basicAllocator = 0)
explicit

Create a task manager having no message handlers. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Message handlers can be supplied using the return value of the controlManager method. If that return value is used to create other PipeTaskManager objects, this object (the owner of the internal ControlManager must outlive those other objects. The start method must be called successfully before messages will be received (on a separate thread created by start). Note that the name of the message pipe is supplied as an argument to start.

◆ PipeTaskManager() [2/2]

balb::PipeTaskManager::PipeTaskManager ( bsl::shared_ptr< ControlManager > &  controlManager,
bslma::Allocator basicAllocator = 0 
)
explicit

Create a task manager that uses the handlers of the specified shared controlManager. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The start method must be called successfully before messages will be received (on a separate thread created by start). Note that the name of the message pipe is supplied as an argument to start. Also note that the handlers of controlManager can be manipulated via the return value of the controlManager method. Finally note that the allocator of controlManger need not equal basicAllocator.

◆ ~PipeTaskManager()

balb::PipeTaskManager::~PipeTaskManager ( )

Shutdown message handling, and release the shared reference to the controlManager (destroying the ConstrolManager and its message handlers if this is the last shared reference), and destroy this object.

Member Function Documentation

◆ allocator()

bslma::Allocator * balb::PipeTaskManager::allocator ( ) const
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.

◆ BSLMF_NESTED_TRAIT_DECLARATION()

balb::PipeTaskManager::BSLMF_NESTED_TRAIT_DECLARATION ( PipeTaskManager  ,
bslma::UsesBslmaAllocator   
)

◆ controlManager() [1/2]

balb::ControlManager & balb::PipeTaskManager::controlManager ( )
inline

Return a non-const reference to the ControlManager object of this PipeTaskManager.

◆ controlManager() [2/2]

const balb::ControlManager & balb::PipeTaskManager::controlManager ( ) const
inline

Return a const reference to the ControlManager object of this PipeTaskManager.

◆ pipeName()

const bsl::string & balb::PipeTaskManager::pipeName ( ) const
inline

Return the path of the named pipe used by the implementation. The behavior is undefined unless the task manager has been started.

◆ shutdown()

void balb::PipeTaskManager::shutdown ( )
inline

Stop processing incoming messages by the background thread. If a handler is executing at the time of invocation, that handler is allowed to complete. This method does not block the caller, and the background thread persists until it is joined by a call to stop. Note that shutdown and stop are typically called in succession.

◆ start()

int balb::PipeTaskManager::start ( const bsl::string_view pipeBasename)

Create a named pipe using the specified pipeBasename (not a pathname), and execute the task manager event processor in a background thread. Return 0 on success, and a non-zero value otherwise. See {Requirements for the Named Pipe} for expectations for pipeBasename. After a successful return, calls to start fail until stop has been called (successfully); afterwards, start can be called again with the same or some other pipeBasename. Note that the pipeName() method provides the (full) pathname to the created named pipe.

◆ stop()

int balb::PipeTaskManager::stop ( )
inline

Block until the background processing thread has shutdown (which must be initiated by a separate call to shutdown) then join the background thread, remove the named pipe, and return. Return 0 on success, and a non-zero value otherwise. If shutdown has not been called, this method will block indefinitely until another thread calls shutdown. Once stop has returned, start can be called again with the same or a different named pipe. Note that frequently user code will call shutdown and then immediately call stop on a TaskManager object.


The documentation for this class was generated from the following file: