Browse Source

Split JackWaitThreadedDriver's Execute method

This makes it possible to use JackWaitThreadedDriver as a base class
for a non-threaded version.
tags/v1.9.11-RC1
Cédric Schieli 10 years ago
parent
commit
c1ae33f934
2 changed files with 19 additions and 10 deletions
  1. +13
    -8
      common/JackWaitThreadedDriver.cpp
  2. +6
    -2
      common/JackWaitThreadedDriver.h

+ 13
- 8
common/JackWaitThreadedDriver.cpp View File

@@ -37,16 +37,21 @@ bool JackWaitThreadedDriver::Init()

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
while (fThread.GetStatus() == JackThread::kRunning) {


+ 6
- 2
common/JackWaitThreadedDriver.h 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 */
};




Loading…
Cancel
Save