Processor.hpp

This File On Github
Ask A Question

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

Processor

Asynchronous Processor.
Responsible for processing and managing multiple Coroutines. Do not use bare processor to run coroutines. Use oatpp::async::Executor instead;.

namespace oatpp { namespace async { 
  class Processor {}
}}

Methods

Return Type Name Summary
void addWorker Add dedicated co-worker to processor.
void pushOneTask Push one Coroutine back to processor.
void pushTasks Push list of Coroutines back to processor.
void execute Execute Coroutine.
void waitForTasks Sleep and wait for tasks.
bool iterate Iterate Coroutines.
void stop Stop waiting for new tasks.
v_int32 getTasksCount Get number of all not-finished tasks including tasks rescheduled for processor's co-workers.

Processor::addWorker

Add dedicated co-worker to processor.

void addWorker(const std::shared_ptr<worker::Worker>& worker)

Processor::pushOneTask

Push one Coroutine back to processor.

void pushOneTask(AbstractCoroutine* coroutine)

Processor::pushTasks

Push list of Coroutines back to processor.

void pushTasks(oatpp::collection::FastQueue<AbstractCoroutine>& tasks)

Processor::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)

Processor::waitForTasks

Sleep and wait for tasks.

void waitForTasks()

Processor::iterate

Iterate Coroutines.

  • @param numIterations - number of iterations.
  • @return - true if there are active Coroutines.

bool iterate(v_int32 numIterations)

Processor::stop

Stop waiting for new tasks.

void stop()

Processor::getTasksCount

Get number of all not-finished tasks including tasks rescheduled for processor's co-workers.

  • @return - number of not-finished tasks.

v_int32 getTasksCount()