Executor.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/core/async/Executor.hpp"

Executor

Asynchronous Executor.
Executes coroutines in multiple oatpp::async::Processor allocating one thread per processor.

namespace oatpp { namespace async { 
  class Executor {}
}}

Fields

Type Name Summary
const v_int32 THREAD_NUM_DEFAULT Default number of threads to run coroutines.

Methods

Return Type Name Summary
[none] Executor Constructor.
[none] ~Executor Non-virtual Destructor.
void join Join all worker-threads.
void detach Detach all worker-threads.
void stop Stop Executor.
void execute Execute Coroutine.
v_int32 getTasksCount Get number of all not finished tasks.
void waitTasksFinished Wait until all tasks are finished.

Executor::THREAD_NUM_DEFAULT

Default number of threads to run coroutines.

static const v_int32 THREAD_NUM_DEFAULT

Executor::Executor

Constructor.

  • @param processorWorkersCount - number of data processing workers.
  • @param ioWorkersCount - number of I/O processing workers.
  • @param timerWorkersCount - number of timer processing workers.

Executor(v_int32 processorWorkersCount = THREAD_NUM_DEFAULT,
         v_int32 ioWorkersCount = 1,
         v_int32 timerWorkersCount = 1)

Executor::~Executor

Non-virtual Destructor.

~Executor()

Executor::join

Join all worker-threads.

void join()

Executor::detach

Detach all worker-threads.

void detach()

Executor::stop

Stop Executor.
After all worker-threads are stopped. Join should unblock.

void stop()

Executor::execute

Execute Coroutine.

  • @tparam CoroutineType - type of coroutine to execute.
  • @tparam Args - types of arguments to be passed to Coroutine constructor.
  • @param params - actual arguments to be passed to Coroutine constructor.

template<typename CoroutineType, typename ... Args>
void execute(Args... params)

Executor::getTasksCount

Get number of all not finished tasks.

  • @return - number of all not finished tasks.

v_int32 getTasksCount()

Executor::waitTasksFinished

Wait until all tasks are finished.

  • @param timeout

void waitTasksFinished(const std::chrono::duration<v_int64, std::micro>& timeout = std::chrono::minutes(1))