16#include <dispatch/dispatch.h>
132 return lhs.mExecutionContext == rhs.mExecutionContext && lhs.mBlockingProperty == rhs.mBlockingProperty;
139 friend struct asio_query_fn::impl;
140 friend struct asio::execution::detail::context_t<0>;
141 friend struct asio::execution::detail::mapping_t<0>;
142 friend struct asio::execution::detail::blocking_t<0>;
143 friend struct asio::execution::detail::relationship_t<0>;
144 friend struct asio::execution::detail::outstanding_work_t<0>;
145 friend struct asio::execution::detail::bulk_guarantee_t<0>;
146 friend struct asio::execution::detail::occupancy_t<0>;
173 switch(mExecutionContext->
mType) {
175 default:
return std::thread::hardware_concurrency();
181 static std::allocator<void> allocator;
187 static std::allocator<void> allocator;
192 friend struct asio_require_fn::impl;
193 friend struct asio_prefer_fn::impl;
220 friend struct asio_execution_execute_fn::impl;
225 mExecutionContext->
schedule(std::move(f), mBlockingProperty, mPriority);
#define CE_ASSERT(...)
Definition Macros.hpp:323
An executor object that dispatches calls to a libdispatch queue.
Definition AppleDispatchQueue.hpp:83
Executor & operator=(const Executor &)=default
static constexpr ExecutorOutstandingWork query(ExecutorOutstandingWork) noexcept
Query the current value of the outstanding_work property.
Definition AppleDispatchQueue.hpp:164
Executor & operator=(Executor &&)=default
Executor require(ExecutorPriority newPriority) const
Obtain an executor with the given priority property.
Definition AppleDispatchQueue.hpp:217
AppleDispatchQueue & context() const noexcept
Obtain the underlying execution context.
Definition AppleDispatchQueue.hpp:115
Executor(Executor &&)=default
Executor(const Executor &)=default
friend bool operator!=(const Executor &lhs, const Executor &rhs) noexcept
Compare two executors for inequality.
Definition AppleDispatchQueue.hpp:136
ExecutorBlocking query(ExecutorBlocking) const noexcept
Query the current value of the blocking property.
Definition AppleDispatchQueue.hpp:155
std::allocator< void > query(ExecutorAllocator< void >) const noexcept
Query the current value of the allocator property.
Definition AppleDispatchQueue.hpp:186
void execute(ASIO_MOVE_ARG(Function) f) const
Execution function.
Definition AppleDispatchQueue.hpp:223
AppleDispatchQueue & query(ExecutorExecutionContext) const noexcept
Query the current value of the context property.
Definition AppleDispatchQueue.hpp:149
Executor require(ExecutorBlocking blocking) const
Obtain an executor with the given blocking property.
Definition AppleDispatchQueue.hpp:205
static constexpr ExecutorRelationship query(ExecutorRelationship) noexcept
Query the current value of the relationship property.
Definition AppleDispatchQueue.hpp:161
static constexpr ExecutorMapping query(ExecutorMapping) noexcept
Query the current value of the mapping property.
Definition AppleDispatchQueue.hpp:152
friend bool operator==(const Executor &lhs, const Executor &rhs) noexcept
Compare two executors for equality.
Definition AppleDispatchQueue.hpp:131
ExecutorPriority query(ExecutorPriority) const noexcept
Query the current value of the priority property.
Definition AppleDispatchQueue.hpp:158
std::allocator< void > query(ExecutorAllocator< OtherAllocator >) const noexcept
Query the current value of the allocator property.
Definition AppleDispatchQueue.hpp:180
void on_work_finished() const noexcept
Inform the executor that some work is no longer outstanding.
Definition AppleDispatchQueue.hpp:124
std::size_t query(ExecutorOccupancy) const noexcept
Query the occupancy (recommended number of work items) for the system context.
Definition AppleDispatchQueue.hpp:171
static constexpr ExecutorBulkGuarantee query(ExecutorBulkGuarantee) noexcept
Query the current value of the bulk_guarantee property.
Definition AppleDispatchQueue.hpp:167
Executor(AppleDispatchQueue &executionContext, ExecutorBlocking blockingProperty=ExecutorBlocking::never, ExecutorPriority priority=ExecutorPriority::Normal)
Creates a new Executor instance.
Definition AppleDispatchQueue.hpp:103
void on_work_started() const noexcept
Inform the executor that it has some outstanding work to do.
Definition AppleDispatchQueue.hpp:118
AppleDispatchQueue * mExecutionContext
The execution context that the executor will use.
Definition AppleDispatchQueue.hpp:88
Abstracts a libdispatch queue as an ASIO execution context.
Definition AppleDispatchQueue.hpp:21
AnyExecutor getExecutor() noexcept final
Returns an executor that run execute scheduled commands on the context.
Definition AppleDispatchQueue.hpp:229
dispatch_queue_t mQueue
The dispatch_queue_t instance to execute commands on.
Definition AppleDispatchQueue.hpp:27
AppleDispatchQueue(const String &name, DispatchQueueType type, AppleDispatchQueue *const queue=nullptr) noexcept
Creates a new Apple queue instance.
void resume() final
Resumes the invocation of block objects on a queue.
void onWorkStarted() noexcept
Inform the executor that it has some outstanding work to do.
dispatch_queue_t getDispatchQueue() const noexcept
The dispatch_queue_t instance to execute commands on.
Definition AppleDispatchQueue.hpp:60
executor_type get_executor() noexcept
Returns an executor that run execute scheduled commands on the context.
Definition AppleDispatchQueue.hpp:230
DispatchQueueType mType
Determines the type of dispatch queue.
Definition AppleDispatchQueue.hpp:30
void suspend() final
Suspends the invocation of function objects on a queue.
void onWorkFinished() noexcept
Inform the executor that some work is no longer outstanding.
UPtr< DispatchQueue > createSubQueue(DispatchQueueType type, StringView name="") final
Resumes the invocation of block objects on a queue.
void schedule(UniqueFunction< void()> function, ExecutorBlocking blockingProperty, ExecutorPriority priority)
Schedules a new function to be run in the run loop.
An object that manages the execution of tasks serially or concurrently on your app's main thread or o...
Definition DispatchQueue.hpp:36
Definition Application.hpp:19
std::unique_ptr< T, Deleter > UPtr
UPtr is a smart pointer that owns and manages another object through a pointer and disposes of that o...
Definition SmartPtr.hpp:28
asio::execution::context_t ExecutorExecutionContext
Definition ExecutionContext.hpp:208
asio::execution::relationship_t ExecutorRelationship
Definition ExecutionContext.hpp:215
asio::execution::mapping_t ExecutorMapping
Definition ExecutionContext.hpp:211
asio::execution::bulk_guarantee_t ExecutorBulkGuarantee
Definition ExecutionContext.hpp:214
asio::execution::occupancy_t ExecutorOccupancy
Definition ExecutionContext.hpp:212
FunctionBase< true, true, fu2::capacity_default, true, false, Signatures... > Function
An owning copyable function wrapper for arbitrary callable types.
Definition Function.hpp:54
DispatchQueueType
Specifies the type of the queue.
Definition DispatchQueue.hpp:17
@ Serial
A dispatch queue that executes blocks serially in FIFO order.
asio::execution::allocator_t< T > ExecutorAllocator
Definition ExecutionContext.hpp:216
asio::execution::blocking_t ExecutorBlocking
Definition ExecutionContext.hpp:210
asio::execution::outstanding_work_t ExecutorOutstandingWork
Definition ExecutionContext.hpp:213
ASIO_MOVE_ARG(CompletionToken) token)
Definition IdleService.hpp:42
FunctionBase< true, false, fu2::capacity_default, true, false, Signatures... > UniqueFunction
An owning non copyable function wrapper for arbitrary callable types.
Definition Function.hpp:59
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Determines the priority to which an executor should schedule its tasks.
Definition ExecutionContext.hpp:220
static const ExecutorPriority Normal
The default value for regular tasks.
Definition ExecutionContext.hpp:250