Add direct mode to Worker::execute()
Sometimes that's what you want, but primarily for completeness' sake and it makes AUTO more sensical as it essentially chooses beteen DIRECT and QUEUED mode.
This commit is contained in:
@ -306,8 +306,9 @@ public:
|
||||
|
||||
enum execute_mode_t
|
||||
{
|
||||
EXECUTE_AUTO, /**< Execute tasks immediately */
|
||||
EXECUTE_QUEUED /**< Only queue tasks for execution */
|
||||
EXECUTE_DIRECT, /**< Always execute directly using the calling thread/worker. */
|
||||
EXECUTE_QUEUED, /**< Always execute via the event loop using this thread/worker. */
|
||||
EXECUTE_AUTO, /**< If calling thread/worker is this worker, call directly otherwise queued. */
|
||||
};
|
||||
|
||||
struct Call
|
||||
|
@ -414,7 +414,8 @@ bool Worker::execute(Task* pTask, mxb::Semaphore* pSem, enum execute_mode_t mode
|
||||
// No logging here, function must be signal safe.
|
||||
bool rval = true;
|
||||
|
||||
if (mode == Worker::EXECUTE_AUTO && Worker::get_current() == this)
|
||||
if ((mode == Worker::EXECUTE_DIRECT)
|
||||
|| (mode == Worker::EXECUTE_AUTO && Worker::get_current() == this))
|
||||
{
|
||||
pTask->execute(*this);
|
||||
|
||||
@ -447,7 +448,8 @@ bool Worker::post_disposable(DisposableTask* pTask, enum execute_mode_t mode)
|
||||
|
||||
pTask->inc_ref();
|
||||
|
||||
if (mode == Worker::EXECUTE_AUTO && Worker::get_current() == this)
|
||||
if ((mode == Worker::EXECUTE_DIRECT)
|
||||
|| (mode == Worker::EXECUTE_AUTO && Worker::get_current() == this))
|
||||
{
|
||||
pTask->execute(*this);
|
||||
pTask->dec_ref();
|
||||
|
Reference in New Issue
Block a user