Update README.md

This commit is contained in:
Jaremy Creechley 2024-02-14 22:20:06 -07:00 committed by GitHub
parent 5c3b379885
commit 8e8a090b0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,9 +3,45 @@
> *Apatheia* (*Greek: ἀπάθεια; from a- "without" and pathos "suffering" or "passion"*), in Stoicism, refers to a state of mind in which one is not disturbed by the passions. It might better be translated by the word equanimity than the word indifference.
WIP utilities for using Chronos async with threading. The desire is to provide safe, pre-tested constructs for using threads with async.
The goal of the apatheia library is to provide a painless, suffering free multi-threading compatible with async.
Goals:
The main modules are:
- queues - queues with support for async signals
- jobs - macro and utilities for submitting jobs to a taskpool
- tasks - convenience wrapper to turn a proc into a job with a simple API
Example usage:
```nim
import taskpools
import apatheia/tasks
proc addNums(a, b: float): float {.asyncTask.} =
os.sleep(50)
return a + b
proc addNumValues(vals: openArray[float]): float {.asyncTask.} =
os.sleep(100)
result = 0.0
for x in vals:
result += x
suite "async tests":
var tp = Taskpool.new(num_threads = 2) # Default to the number of hardware threads.
asyncTest "test addNums":
var jobs = newJobQueue[float](taskpool = tp)
let res = await jobs.submit(addNums(1.0, 2.0,))
check res == 3.0
asyncTest "test addNumValues":
var jobs = newJobQueue[float](taskpool = tp)
let args = @[1.0, 2.0, 3.0]
let res = await jobs.submit(addNumValues(args))
check res == 6.0
```
Future Goals:
- support orc and refc
+ refc may require extra copying for data