Turi Create  4.0
turi::neural_net::TaskQueue Class Referenceabstract

Abstract task queue interface modeled after Grand Central Dispatch. More...

#include <ml/neural_net/TaskQueue.hpp>

Public Member Functions

virtual void DispatchAsync (std::function< void()> task)=0
 
virtual void DispatchSync (std::function< void()> task)=0
 
virtual void DispatchApply (size_t n, std::function< void(size_t i)> task)=0
 

Static Public Member Functions

static std::shared_ptr< TaskQueueGetGlobalConcurrentQueue ()
 
static std::unique_ptr< TaskQueueCreateSerialQueue (const char *label)
 

Detailed Description

Abstract task queue interface modeled after Grand Central Dispatch.

Definition at line 17 of file TaskQueue.hpp.

Member Function Documentation

◆ CreateSerialQueue()

static std::unique_ptr<TaskQueue> turi::neural_net::TaskQueue::CreateSerialQueue ( const char *  label)
static

Returns a task queue that guarantees that if task A is submitted before task B, then task A will finish before task B begins. Accepts a label that may be used by the system to identify work done by this queue.

◆ DispatchApply()

virtual void turi::neural_net::TaskQueue::DispatchApply ( size_t  n,
std::function< void(size_t i)>  task 
)
pure virtual

Submits a function to this task queue n times, with arguments ranging from 0 to n - 1. When dispatched to a concurrent queue, the function must be reentrant. Rethrows the first exception thrown by any task invocation.

Implemented in turi::neural_net::GlobalPosixTaskQueue, turi::neural_net::SerialPosixTaskQueue, and turi::neural_net::GrandCentralDispatchQueue.

◆ DispatchAsync()

virtual void turi::neural_net::TaskQueue::DispatchAsync ( std::function< void()>  task)
pure virtual

Submits a function to this task queue without waiting for the function to finish. The task must not throw an exception.

Implemented in turi::neural_net::GrandCentralDispatchQueue, and turi::neural_net::PosixTaskQueue.

◆ DispatchSync()

virtual void turi::neural_net::TaskQueue::DispatchSync ( std::function< void()>  task)
pure virtual

Submits a function to this task queue and waits for the function to execute. The task must not throw an exception.

Implemented in turi::neural_net::GrandCentralDispatchQueue, and turi::neural_net::PosixTaskQueue.

◆ GetGlobalConcurrentQueue()

static std::shared_ptr<TaskQueue> turi::neural_net::TaskQueue::GetGlobalConcurrentQueue ( )
static

Returns a task queue that does not enforce any ordering among its tasks and that shares system resources with other task queues created by this function.


The documentation for this class was generated from the following file: