Skip to content

heiher/hev-task-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ed320fd · Feb 28, 2025
Feb 16, 2025
Mar 15, 2020
Jan 14, 2024
Feb 28, 2025
Feb 14, 2025
Oct 19, 2018
Oct 1, 2024
Jan 14, 2024
Nov 6, 2018
Jun 8, 2022
Jan 14, 2024
Feb 15, 2025
Oct 1, 2024
Nov 8, 2018
Jan 14, 2024
Oct 1, 2024

Repository files navigation

HevTaskSystem

status

HevTaskSystem is a simple, lightweight multi-task system (coroutines).

The task system is executed within a native process/thread. In task system, you can create many tasks and attach them to the task system. When a task yields or is blocked by I/O, the scheduler will pick a suitable task from running list and switch to it. Memory space, file descriptors, and other resources are shared among all tasks in the task system. Each task has its private, standalone task structure (#HevTask) and stack in heap of the process.

Within a task, you can allocate memory from heap, read and write data to the stack, and perform I/O operations in synchronized mode.

Features

  • Simple/lightweight task.
  • I/O operations wrapper.
  • Inter-task synchronous. (Mutex/Condition)
  • Inter-task communications. (Channel)
  • Slice-based memory allocator.
  • Call on new stack.
  • Multi-thread support.
  • Multi-platform support. (Linux/BSD/macOS/Windows)

How to Build

Unix

git clone https://gitlab.com/hev/hev-task-system
cd hev-task-system
make

# Link with librt (only for glibc versions before 2.17)
make LDFLAGS=-lrt

# Disable stack overflow detection
make ENABLE_STACK_OVERFLOW_DETECTION=0

# Set stack backend to heap (Recommended for 32-bit)
make CONFIG_STACK_BACKEND=STACK_HEAP

# Disable sliced memory allocator
make ENABLE_MEMALLOC_SLICE=0

# Disable I/O splice by splice syscall (for old Linux kernel)
make ENABLE_IO_SPLICE_SYSCALL=0

# Demos
make apps

# Tests
make tests

Android

mkdir hev-task-system
cd hev-task-system
git clone https://gitlab.com/hev/hev-task-system jni
ndk-build

iOS and MacOS

git clone https://gitlab.com/hev/hev-task-system
cd hev-task-system
# will generate HevTaskSystem.xcframework
./build-apple.sh

Windows (MSYS2)

export MSYS=winsymlinks:native
git clone https://gitlab.com/hev/hev-task-system
cd hev-task-system
make LFLAGS="-lmsys-2.0 -lws2_32"

Demos

  1. simple
  2. channel
  3. timeout
  4. wakeup
  5. echo-server
  6. call
  7. gtk
  8. curl

Contributors

License

MIT