Single-thread executor implementation.
More...
#include <Executor.h>
Single-thread executor implementation.
An Executor is used to run callable types asynchronously.
This type is a wrapper around ExecutorInterface implementation.
◆ Executor() [1/2]
alexaClientSDK::avsCommon::utils::threading::Executor::Executor |
( |
| ) |
|
|
noexcept |
◆ Executor() [2/2]
alexaClientSDK::avsCommon::utils::threading::Executor::Executor |
( |
const std::chrono::milliseconds & |
unused | ) |
|
|
inlinenoexcept |
◆ ~Executor()
alexaClientSDK::avsCommon::utils::threading::Executor::~Executor |
( |
| ) |
|
|
noexcept |
◆ execute() [1/2]
bool alexaClientSDK::avsCommon::utils::threading::Executor::execute |
( |
std::function< void()> && |
function | ) |
|
|
noexcept |
Schedules a function for execution.
Submits a function to be executed on an Executor thread.
- Parameters
-
[in] | function | Function to execute. Function must not be empty. |
- Returns
- True if function is accepted for execution, false if function is empty or executor is shutdown.
◆ execute() [2/2]
bool alexaClientSDK::avsCommon::utils::threading::Executor::execute |
( |
const std::function< void()> & |
function | ) |
|
|
noexcept |
Schedules a function for execution.
Submits a function to be executed on an Executor thread.
- Parameters
-
[in] | function | Function to execute. |
- Returns
- True if function is accepted for execution, false if function is empty or executor is shutdown.
◆ isShutdown()
bool alexaClientSDK::avsCommon::utils::threading::Executor::isShutdown |
( |
| ) |
|
|
noexcept |
Returns whether or not the executor is shutdown.
◆ operator std::shared_ptr< ExecutorInterface >()
alexaClientSDK::avsCommon::utils::threading::Executor::operator std::shared_ptr< ExecutorInterface > |
( |
| ) |
const |
|
noexcept |
◆ shutdown()
void alexaClientSDK::avsCommon::utils::threading::Executor::shutdown |
( |
| ) |
|
|
noexcept |
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...))> |
|
noexcept |
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.
- Template Parameters
-
Task | Callable type. |
Args | Argument types. |
- Parameters
-
task | A callable type representing a task. |
args | The arguments to call the task with. |
- Returns
- A
std::future
for the return value of the task.
- Note
- This method is less memory and speed efficient then execute() and should not be used unless std::future result is required.
◆ submitToFront()
template<typename Task , typename... Args>
auto alexaClientSDK::avsCommon::utils::threading::Executor::submitToFront |
( |
Task |
task, |
|
|
Args &&... |
args |
|
) |
| -> std::future<decltype(task(args...))> |
|
noexcept |
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.
- Template Parameters
-
Task | Callable type. |
Args | Argument types. |
- Parameters
-
task | A callable type representing a task. |
args | The arguments to call the task with. |
- Returns
- A
std::future
for the return value of the task.
- Note
- This method is less memory and speed efficient then execute() and should not be used unless std::future result is required.
◆ waitForSubmittedTasks()
void alexaClientSDK::avsCommon::utils::threading::Executor::waitForSubmittedTasks |
( |
| ) |
|
|
noexcept |
Waits for any previously submitted tasks to complete.
The documentation for this class was generated from the following file:
- /workplace/avs-device-sdk/AVSCommon/Utils/include/AVSCommon/Utils/Threading/Executor.h
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0