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

Interface for asynchronous execution of functions. More...

#include <ExecutorInterface.h>

Public Member Functions

virtual ~ExecutorInterface () noexcept=default
 Destructs an Executor. More...
 
virtual std::error_condition execute (std::function< void()> &&function) noexcept=0
 Schedules a function for execution. More...
 
virtual std::error_condition execute (const std::function< void()> &function) noexcept=0
 Schedules a function for execution. More...
 

Detailed Description

Interface for asynchronous execution of functions.

This interface enables submission of functions for asynchronous execution. The implementations should use thread pool to acquire threads for running functions, and may be single- or multi-threaded.

Executors can be in normal mode, when they accept tasks, and in shutdown mode. In shutdown mode executors do not accept new tasks for processing, and any tasks, that haven't started an execution will be dropped.

auto error = executor->execute([]{ ... });
if (error) {
ACSDK_ERROR(LX(__func__).("executorError", error.message()));
}
See also
Executor
ThreadPool

Constructor & Destructor Documentation

◆ ~ExecutorInterface()

virtual alexaClientSDK::avsCommon::utils::threading::ExecutorInterface::~ExecutorInterface ( )
virtualdefaultnoexcept

Destructs an Executor.

This method awaits till all running tasks are completed, and drops all enqueued tasks that haven't started execution.

Member Function Documentation

◆ execute() [1/2]

virtual std::error_condition alexaClientSDK::avsCommon::utils::threading::ExecutorInterface::execute ( std::function< void()> &&  function)
pure virtualnoexcept

Schedules a function for execution.

Submits a function to be executed on an executor thread.

Parameters
[in]functionFunction to execute. Function must not be empty.
Returns
Platform-independent error code. If successful, the error value is zero.
Return values
std::errc::invalid_argumentIf function is empty.
std::errc::operation_not_permittedIf executor is shutdown.

◆ execute() [2/2]

virtual std::error_condition alexaClientSDK::avsCommon::utils::threading::ExecutorInterface::execute ( const std::function< void()> &  function)
pure virtualnoexcept

Schedules a function for execution.

Submits a function to be executed on an executor thread.

Parameters
[in]functionFunction to execute. Function must not be empty.
Returns
Platform-independent error code. If successful, the error value is zero.
Return values
std::errc::invalid_argumentIf function is empty.
std::errc::operation_not_permittedIf executor is shutdown.

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

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