This class implements an execution of tasks pulled off an input queue.
More...
#include <Executor.hxx>
|
| class | Service |
| | provide access to Executor::send method.
|
| |
This class implements an execution of tasks pulled off an input queue.
Definition at line 63 of file Executor.hxx.
◆ ExecutorBase()
| ExecutorBase::ExecutorBase |
( |
| ) |
|
Constructor.
- Todo:
- (Stuart Baker) is "name" still in use?
Definition at line 73 of file Executor.cxx.
◆ ~ExecutorBase()
| ExecutorBase::~ExecutorBase |
( |
| ) |
|
◆ active_timers()
- Returns
- the list of active timers.
Definition at line 144 of file Executor.hxx.
◆ add()
| virtual void ExecutorBase::add |
( |
Executable * |
action, |
|
|
unsigned |
priority = UINT_MAX |
|
) |
| |
|
pure virtual |
◆ assert_current()
| void ExecutorBase::assert_current |
( |
| ) |
|
|
inline |
Die if we are not on the current executor.
Definition at line 160 of file Executor.hxx.
◆ by_name()
Lookup an executor by its name.
- Parameters
-
| name | name of executor to lookup |
| wait | wait forever for an executor to show up |
- Returns
- pointer to executor upon success, else NULL if not found
- Parameters
-
| name | name of executor to lookup |
- Returns
- pointer to executor upon success, else NULL if not found
- Todo:
- (Stuart Baker) we need a locking mechanism here to protect the list.
Definition at line 90 of file Executor.cxx.
◆ current()
Helper function for debugging and tracing.
- Returns
- currently running executable or nullptr if none active.
Definition at line 168 of file Executor.hxx.
◆ empty()
| virtual bool ExecutorBase::empty |
( |
| ) |
|
|
pure virtual |
◆ entry()
| void * ExecutorBase::entry |
( |
| ) |
|
|
overrideprotectedvirtual |
Thread entry point.
- Returns
- Should never return
Reimplemented from OSThread.
Definition at line 293 of file Executor.cxx.
◆ get_select_set()
Helper function.
- Parameters
-
| type | a select type: READ, WRITE or EXCEPT |
- Returns
- the fd_set that's being waited for that given select type.
Definition at line 201 of file Executor.hxx.
◆ is_selected()
- Returns
- true if the given job's FD is currently enqueued for a select. This may or may not mean that the specific job is waiting for a select call. If this returns true, it does mean that trying to select() that job will cause a crash, since the same FD cannot be selected more than once.
- Parameters
-
| job | is the selectable to query. |
Definition at line 352 of file Executor.cxx.
◆ loop_once()
| bool ExecutorBase::loop_once |
( |
| ) |
|
Performs one loop of the execution on the calling thread.
- Returns
- true if there is more scheduled work to do. Returns false if the executor loop would block right now.
Definition at line 165 of file Executor.cxx.
◆ loop_some()
Performs a few loops of the executor on the calling thread.
- Returns
- 0 if there is still pending work scheduled on the executor, non-zero if there is some work to do after a sleep. The returned value is the nanoseconds to sleep before calling loop_some again.
Definition at line 187 of file Executor.cxx.
◆ next()
| virtual Executable * ExecutorBase::next |
( |
unsigned * |
priority | ) |
|
|
privatepure virtual |
◆ run()
| void ExecutorBase::run |
( |
| ) |
|
|
inlineoverrideprotectedvirtual |
Entry point.
This funciton will be called when *this gets scheduled on the CPU.
Implements Executable.
Definition at line 176 of file Executor.hxx.
◆ select()
Adds a file descriptor to be watched to the select loop.
- Parameters
-
| job | Selectable structure that describes the descriptor to watch. The pointer must stay alive until it is activated, or is unselected. |
Must be called on the executor thread.
- Parameters
-
| job | is a Selectable pointer that is not currently watched. |
Definition at line 332 of file Executor.cxx.
◆ sequence()
| virtual uint32_t ExecutorBase::sequence |
( |
| ) |
|
|
pure virtual |
◆ shutdown()
| void ExecutorBase::shutdown |
( |
| ) |
|
Terminates the executor thread.
Waits until it is safe to delete the executor.
Definition at line 437 of file Executor.cxx.
◆ sync_run()
| void ExecutorBase::sync_run |
( |
std::function< void()> |
fn | ) |
|
Synchronously runs a closure on this executor.
Does not return until the execution is completed.
- Parameters
-
Definition at line 151 of file Executor.cxx.
◆ thread()
◆ thread_handle()
| os_thread_t ExecutorBase::thread_handle |
( |
| ) |
|
|
inline |
◆ unselect()
Removes a job from the select loop.
This stops watching the given file descriptor. The job must have been previously inserted into the Executor and must be not yet activated.
Must be called on the executor thread.
- Parameters
-
| job | is a Selectable pointer that was previously inserted. |
Definition at line 359 of file Executor.cxx.
◆ wait_with_select()
| void ExecutorBase::wait_with_select |
( |
long long |
next_timer_nsec | ) |
|
|
private |
Executes a select call, and schedules any necessary executables based on the return.
Will not sleep at all if not empty, otherwise sleeps at most next_timer_nsec nanoseconds (from now).
- Parameters
-
| next_timer_nsec | is the maximum time to sleep in nanoseconds. |
Definition at line 384 of file Executor.cxx.
◆ Service
provide access to Executor::send method.
Definition at line 247 of file Executor.hxx.
◆ activeTimers_
◆ current_
Currently executing closure.
USeful for debugging crashes.
Definition at line 217 of file Executor.hxx.
◆ done_
| std::atomic_uint_least8_t ExecutorBase::done_ |
|
private |
Set to 1 when the executor thread has exited and it is safe to delete *this.
Definition at line 235 of file Executor.hxx.
◆ name_
| const char* ExecutorBase::name_ |
|
private |
◆ selectables_
Head of the linked list for the select calls.
Definition at line 231 of file Executor.hxx.
◆ selectExcept_
| fd_set ExecutorBase::selectExcept_ |
|
private |
◆ selectHelper_
Helper object for interruptible select calls.
Definition at line 179 of file Executor.hxx.
◆ selectNFds_
| int ExecutorBase::selectNFds_ |
|
private |
◆ selectPrescaler_
| unsigned ExecutorBase::selectPrescaler_ |
|
private |
How many executables we schedule blindly before calling a select() in order to find more data to read/write in the FDs being waited upon.
Definition at line 240 of file Executor.hxx.
◆ selectRead_
| fd_set ExecutorBase::selectRead_ |
|
private |
◆ selectWrite_
| fd_set ExecutorBase::selectWrite_ |
|
private |
◆ sequence_
| volatile unsigned ExecutorBase::sequence_ |
|
protected |
◆ started_
| std::atomic_uint_least8_t ExecutorBase::started_ |
|
private |
1 if the executor is already running
Definition at line 237 of file Executor.hxx.
The documentation for this class was generated from the following files: