Split JackWaitThreadedDriver's Execute method

This makes it possible to use JackWaitThreadedDriver as a base class
for a non-threaded version.
This commit is contained in:
Cédric Schieli 2014-10-29 19:09:56 +01:00
parent 61efee41a7
commit c1ae33f934
2 changed files with 20 additions and 11 deletions

View File

@ -36,18 +36,23 @@ bool JackWaitThreadedDriver::Init()
}
bool JackWaitThreadedDriver::Execute()
{
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();
}
return ExecuteReal();
}
bool JackWaitThreadedDriver::ExecuteReal()
{
try {
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();
}
// Switch to keep running even in case of error
while (fThread.GetStatus() == JackThread::kRunning) {
fDriver->Process();

View File

@ -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 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.
*/
@ -89,6 +89,10 @@ class SERVER_EXPORT JackWaitThreadedDriver : public JackThreadedDriver
// JackRunnableInterface interface
bool Init();
bool Execute();
protected:
virtual bool ExecuteReal(); /*!< Real work to be done when the decorated driver has finish initializing */
};