AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | List of all members
alexaClientSDK::avsCommon::utils::threading::Executor Class Reference

#include <Executor.h>

Public Member Functions

 Executor (const std::chrono::milliseconds &delayExit=std::chrono::milliseconds(1000))
 
 ~Executor ()
 
template<typename Task , typename... Args>
auto submit (Task task, Args &&... args) -> std::future< decltype(task(args...))>
 
template<typename Task , typename... Args>
auto submitToFront (Task task, Args &&... args) -> std::future< decltype(task(args...))>
 
void waitForSubmittedTasks ()
 
void shutdown ()
 Clears the executor of outstanding tasks and refuses any additional tasks to be submitted. More...
 
bool isShutdown ()
 Returns whether or not the executor is shutdown. More...
 

Detailed Description

An Executor is used to run callable types asynchronously.

Constructor & Destructor Documentation

◆ Executor()

alexaClientSDK::avsCommon::utils::threading::Executor::Executor ( const std::chrono::milliseconds &  delayExit = std::chrono::milliseconds(1000))

Constructs an Executor.

Parameters
delayExitThe period of time that this executor will keep its thread running while waiting for a new job. We use 1s by default.

◆ ~Executor()

alexaClientSDK::avsCommon::utils::threading::Executor::~Executor ( )

Destructs an Executor.

Member Function Documentation

◆ isShutdown()

bool alexaClientSDK::avsCommon::utils::threading::Executor::isShutdown ( )

Returns whether or not the executor is shutdown.

◆ shutdown()

void alexaClientSDK::avsCommon::utils::threading::Executor::shutdown ( )

Clears the executor of outstanding tasks and refuses any additional tasks to be submitted.

◆ submit()

template<typename Task , typename... Args>
auto alexaClientSDK::avsCommon::utils::threading::Executor::submit ( Task  task,
Args &&...  args 
) -> std::future<decltype(task(args...))>

Submits a callable type (function, lambda expression, bind expression, or another function object) to be executed on an Executor thread. The future must be checked for validity before waiting on it.

Parameters
taskA callable type representing a task.
argsThe arguments to call the task with.
Returns
A std::future for the return value of the task.

◆ submitToFront()

template<typename Task , typename... Args>
auto alexaClientSDK::avsCommon::utils::threading::Executor::submitToFront ( Task  task,
Args &&...  args 
) -> std::future<decltype(task(args...))>

Submits a callable type (function, lambda expression, bind expression, or another function object) to the front of the internal queue to be executed on an Executor thread. The future must be checked for validity before waiting on it.

Parameters
taskA callable type representing a task.
argsThe arguments to call the task with.
Returns
A std::future for the return value of the task.

◆ waitForSubmittedTasks()

void alexaClientSDK::avsCommon::utils::threading::Executor::waitForSubmittedTasks ( )

Waits for any previously submitted tasks to complete.


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

AlexaClientSDK 1.26.0 - Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0