This makes it possible to use JackWaitThreadedDriver as a base class for a non-threaded version.tags/v1.9.11-RC1
@@ -37,16 +37,21 @@ bool JackWaitThreadedDriver::Init() | |||||
bool JackWaitThreadedDriver::Execute() | bool JackWaitThreadedDriver::Execute() | ||||
{ | { | ||||
try { | |||||
SetRealTime(); | |||||
SetRealTime(); | |||||
// Process a null cycle until NetDriver has started | |||||
while (!fStarter.fRunning && fThread.GetStatus() == JackThread::kRunning) { | |||||
// Use base class method | |||||
assert(static_cast<JackWaiterDriver*>(fDriver)); | |||||
static_cast<JackWaiterDriver*>(fDriver)->ProcessNull(); | |||||
} | |||||
// Process a null cycle until NetDriver has started | |||||
while (!fStarter.fRunning && fThread.GetStatus() == JackThread::kRunning) { | |||||
// Use base class method | |||||
assert(static_cast<JackWaiterDriver*>(fDriver)); | |||||
static_cast<JackWaiterDriver*>(fDriver)->ProcessNull(); | |||||
} | |||||
return ExecuteReal(); | |||||
} | |||||
bool JackWaitThreadedDriver::ExecuteReal() | |||||
{ | |||||
try { | |||||
// Switch to keep running even in case of error | // Switch to keep running even in case of error | ||||
while (fThread.GetStatus() == JackThread::kRunning) { | while (fThread.GetStatus() == JackThread::kRunning) { | ||||
@@ -28,10 +28,10 @@ namespace Jack | |||||
{ | { | ||||
/*! | /*! | ||||
\brief To be used as a wrapper of JackNetDriver. | |||||
\brief Wrapper for a restartable threaded driver (e.g. JackNetDriver). | |||||
The idea is to behave as the "dummy" driver, until the network connection is really started and processing starts. | The idea is to behave as the "dummy" driver, until the network connection is really started and processing starts. | ||||
The Execute method will call the Process method from the base JackTimedDriver, until the decorated driver Init method returns. | |||||
The Execute method will call the ProcessNull method from the base JackWaiterDriver, until the decorated driver Initialize method returns. | |||||
A helper JackDriverStarter thread is used for that purpose. | A helper JackDriverStarter thread is used for that purpose. | ||||
*/ | */ | ||||
@@ -89,6 +89,10 @@ class SERVER_EXPORT JackWaitThreadedDriver : public JackThreadedDriver | |||||
// JackRunnableInterface interface | // JackRunnableInterface interface | ||||
bool Init(); | bool Init(); | ||||
bool Execute(); | bool Execute(); | ||||
protected: | |||||
virtual bool ExecuteReal(); /*!< Real work to be done when the decorated driver has finish initializing */ | |||||
}; | }; | ||||