ESP32  1.0.4
asio::thread_pool::executor_type クラス

Executor used to submit functions to a thread pool. [詳解]

#include <thread_pool.hpp>

公開メンバ関数

thread_poolcontext () const ASIO_NOEXCEPT
 Obtain the underlying execution context. [詳解]
 
void on_work_started () const ASIO_NOEXCEPT
 Inform the thread pool that it has some outstanding work to do. [詳解]
 
void on_work_finished () const ASIO_NOEXCEPT
 Inform the thread pool that some work is no longer outstanding. [詳解]
 
template<typename Function , typename Allocator >
void dispatch (ASIO_MOVE_ARG(Function) f, const Allocator &a) const
 Request the thread pool to invoke the given function object. [詳解]
 
template<typename Function , typename Allocator >
void post (ASIO_MOVE_ARG(Function) f, const Allocator &a) const
 Request the thread pool to invoke the given function object. [詳解]
 
template<typename Function , typename Allocator >
void defer (ASIO_MOVE_ARG(Function) f, const Allocator &a) const
 Request the thread pool to invoke the given function object. [詳解]
 
bool running_in_this_thread () const ASIO_NOEXCEPT
 Determine whether the thread pool is running in the current thread. [詳解]
 

フレンド

class thread_pool
 
bool operator== (const executor_type &a, const executor_type &b) ASIO_NOEXCEPT
 Compare two executors for equality. [詳解]
 
bool operator!= (const executor_type &a, const executor_type &b) ASIO_NOEXCEPT
 Compare two executors for inequality. [詳解]
 

詳解

Executor used to submit functions to a thread pool.

thread_pool.hpp111 行目に定義があります。

関数詳解

◆ context()

thread_pool & asio::thread_pool::executor_type::context ( ) const
inline

Obtain the underlying execution context.

thread_pool.hpp35 行目に定義があります。

36 {
37  return pool_;
38 }

◆ defer()

template<typename Function , typename Allocator >
void asio::thread_pool::executor_type::defer ( ASIO_MOVE_ARG(Function)  f,
const Allocator &  a 
) const

Request the thread pool to invoke the given function object.

This function is used to ask the thread pool to execute the given function object. The function object will never be executed inside defer(). Instead, it will be scheduled to run on the thread pool.

If the current thread belongs to the thread pool, defer() will delay scheduling the function object until the current thread returns control to the pool.

引数
fThe function object to be called. The executor will make a copy of the handler object as required. The function signature of the function object must be:
void function();
aAn allocator that may be used by the executor to allocate the internal storage needed for function invocation.

thread_pool.hpp100 行目に定義があります。

102 {
103  typedef typename decay<Function>::type function_type;
104 
105  // Allocate and construct an operation to wrap the function.
106  typedef detail::executor_op<function_type, Allocator> op;
107  typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 };
108  p.p = new (p.v) op(ASIO_MOVE_CAST(Function)(f), a);
109 
110  ASIO_HANDLER_CREATION((pool_, *p.p,
111  "thread_pool", &this->context(), 0, "defer"));
112 
113  pool_.scheduler_.post_immediate_completion(p.p, true);
114  p.v = p.p = 0;
115 }
macro xchal_ncp_store ptr at1 at2 at3 at4 ofs rur THREADPTR at1 s32i ptr
Definition: tie-asm.h:80
type
Definition: mimetable.h:8
ASIO_DECL void post_immediate_completion(operation *op, bool is_continuation)
void * allocate(std::size_t s, Handler &h)
#define ASIO_MOVE_CAST(type)
Definition: config.hpp:152
#define ASIO_HANDLER_CREATION(args)

◆ dispatch()

template<typename Function , typename Allocator >
void asio::thread_pool::executor_type::dispatch ( ASIO_MOVE_ARG(Function)  f,
const Allocator &  a 
) const

Request the thread pool to invoke the given function object.

This function is used to ask the thread pool to execute the given function object. If the current thread belongs to the pool, dispatch() executes the function before returning. Otherwise, the function will be scheduled to run on the thread pool.

引数
fThe function object to be called. The executor will make a copy of the handler object as required. The function signature of the function object must be:
void function();
aAn allocator that may be used by the executor to allocate the internal storage needed for function invocation.

thread_pool.hpp53 行目に定義があります。

55 {
56  typedef typename decay<Function>::type function_type;
57 
58  // Invoke immediately if we are already inside the thread pool.
59  if (pool_.scheduler_.can_dispatch())
60  {
61  // Make a local, non-const copy of the function.
62  function_type tmp(ASIO_MOVE_CAST(Function)(f));
63 
66  return;
67  }
68 
69  // Allocate and construct an operation to wrap the function.
70  typedef detail::executor_op<function_type, Allocator> op;
71  typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 };
72  p.p = new (p.v) op(ASIO_MOVE_CAST(Function)(f), a);
73 
74  ASIO_HANDLER_CREATION((pool_, *p.p,
75  "thread_pool", &this->context(), 0, "dispatch"));
76 
77  pool_.scheduler_.post_immediate_completion(p.p, false);
78  p.v = p.p = 0;
79 }
macro xchal_ncp_store ptr at1 at2 at3 at4 ofs rur THREADPTR at1 s32i ptr
Definition: tie-asm.h:80
basic_streambuf< Allocator > & b
Definition: read.hpp:689
null_fenced_block fenced_block
void invoke(Function &function, Context &context)
type
Definition: mimetable.h:8
ASIO_DECL void post_immediate_completion(operation *op, bool is_continuation)
void * allocate(std::size_t s, Handler &h)
#define ASIO_MOVE_CAST(type)
Definition: config.hpp:152
#define ASIO_HANDLER_CREATION(args)

◆ on_work_finished()

void asio::thread_pool::executor_type::on_work_finished ( ) const
inline

Inform the thread pool that some work is no longer outstanding.

This function is used to inform the thread pool that some work has finished. Once the count of unfinished work reaches zero, the thread pool's join() function is permitted to exit.

thread_pool.hpp46 行目に定義があります。

48 {
49  pool_.scheduler_.work_finished();
50 }

◆ on_work_started()

void asio::thread_pool::executor_type::on_work_started ( ) const
inline

Inform the thread pool that it has some outstanding work to do.

This function is used to inform the thread pool that some work has begun. This ensures that the thread pool's join() function will not return while the work is underway.

thread_pool.hpp41 行目に定義があります。

42 {
43  pool_.scheduler_.work_started();
44 }

◆ post()

template<typename Function , typename Allocator >
void asio::thread_pool::executor_type::post ( ASIO_MOVE_ARG(Function)  f,
const Allocator &  a 
) const

Request the thread pool to invoke the given function object.

This function is used to ask the thread pool to execute the given function object. The function object will never be executed inside post(). Instead, it will be scheduled to run on the thread pool.

引数
fThe function object to be called. The executor will make a copy of the handler object as required. The function signature of the function object must be:
void function();
aAn allocator that may be used by the executor to allocate the internal storage needed for function invocation.

thread_pool.hpp82 行目に定義があります。

84 {
85  typedef typename decay<Function>::type function_type;
86 
87  // Allocate and construct an operation to wrap the function.
88  typedef detail::executor_op<function_type, Allocator> op;
89  typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 };
90  p.p = new (p.v) op(ASIO_MOVE_CAST(Function)(f), a);
91 
92  ASIO_HANDLER_CREATION((pool_, *p.p,
93  "thread_pool", &this->context(), 0, "post"));
94 
95  pool_.scheduler_.post_immediate_completion(p.p, false);
96  p.v = p.p = 0;
97 }
macro xchal_ncp_store ptr at1 at2 at3 at4 ofs rur THREADPTR at1 s32i ptr
Definition: tie-asm.h:80
type
Definition: mimetable.h:8
ASIO_DECL void post_immediate_completion(operation *op, bool is_continuation)
void * allocate(std::size_t s, Handler &h)
#define ASIO_MOVE_CAST(type)
Definition: config.hpp:152
#define ASIO_HANDLER_CREATION(args)

◆ running_in_this_thread()

bool asio::thread_pool::executor_type::running_in_this_thread ( ) const
inline

Determine whether the thread pool is running in the current thread.

戻り値
true if the current thread belongs to the pool. Otherwise returns false.

thread_pool.hpp118 行目に定義があります。

119 {
120  return pool_.scheduler_.can_dispatch();
121 }

フレンドと関連関数の詳解

◆ operator!=

bool operator!= ( const executor_type a,
const executor_type b 
)
friend

Compare two executors for inequality.

Two executors are equal if they refer to the same underlying thread pool.

thread_pool.hpp207 行目に定義があります。

209  {
210  return &a.pool_ != &b.pool_;
211  }
basic_streambuf< Allocator > & b
Definition: read.hpp:689

◆ operator==

bool operator== ( const executor_type a,
const executor_type b 
)
friend

Compare two executors for equality.

Two executors are equal if they refer to the same underlying thread pool.

thread_pool.hpp197 行目に定義があります。

199  {
200  return &a.pool_ == &b.pool_;
201  }
basic_streambuf< Allocator > & b
Definition: read.hpp:689

◆ thread_pool

friend class thread_pool
friend

thread_pool.hpp214 行目に定義があります。


このクラス詳解は次のファイルから抽出されました: