Skip to content
MinusOne edited this page Feb 18, 2022 · 2 revisions

Execution Library

1. Introduction

"Executor" is library that performs kernel-independent context switching, branch (similar with thread) management and priority - based scheduling. Without kernel scheduler - dependent sleeps and blocking we can boost I/O operation performance and minimize delay between lock-acquire thread and lock-release thread.

2. Components

execution::executor

Basic Executor based on default branch and context. Supports round-robin and priority - based queueing.

1. basic_executor<...>::dispatch method

Dispatches a function call to executor. Executor will pack a function to executable one and enqueue this to execution queue. Dispatched function will be executed as a form of basic_execution_branch<...> and must receive branch_execution_handle<>::branch_handle& in first parameter. The method will return a handle for manipulating running branch (basic_executor<...>::running).

2. basic_executor<...>::suspend method

Suspends a running branch. Branch will be suspended until explicit "resume" call and will be moved into "suspended queue". The method will return a handle for manipulating suspended branch (basic_executor<...>::suspended).

3. basic_executor<...>::resume method

Resumes a suspended branch. Branch will resume to run until explicit "suspend" call or branch reached return statement. The method will return a handle for manipulating running branch (basic_executor<...>::running) and will be moved into execution queue.

4. basic_executor<...>::execute method

Executes next branch in execution queue. Similar with boost::asio::io_context::run() method. Returns true if target branch for execution exists, false if execution queue is empty.

5. basic_executor<...>::trigger_if method

Sets a trigger for any resume/suspend event in basic_executor<...> object. If trigger::suspended delivered into first parameter, basic_executor<...> object will set trigger to executable delivered into second parameter.

* execution::branch

Basic Execution Branch works similar with thread. Every branch - executed function must set its first parameter as "Branch Handle" defined in execution::basic_execution_branch.

3. What is based on

  • "Context" Library
  • (Windows / Linux Both) NASM Assembler
  • (In Windows) VirtualAlloc() / VirtualFree()
  • (In Linux) mmap() / munmap()