Skip to content

Commit

Permalink
Update README for branch lazyrun
Browse files Browse the repository at this point in the history
  • Loading branch information
dermesser committed Oct 7, 2024
1 parent 5c31e50 commit bd9e575
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,6 @@ Supported functionality:
* A threadpool for synchronous or CPU-bound tasks
* A `SelectSet` for polling multiple promises at once

## Context

Promises (backed by coroutines) are run eagerly; you don't have to schedule or await them for the
underlying coroutine to run.

Where I/O or other activity causes a coroutine to be resumed, the coroutine will typically be run by
the scheduler, which you don't need to care about. Depending on the `RunMode`, pending coroutines
are either run once per event loop turn, or immediately from the libuv callback (`Immediate`). By
default, they are run all at once in every event loop turn (`Deferred`). While you can set the run
mode for I/O events in `uvco::runMain()` (`Deferred` vs. `Immediate`), the externally visible
behavior should be the same, and code will work in both modes. If it doesn't: that's a bug in uvco.

Some types - like buffers filled by sockets - use simple types like strings, which are easy to
handle but not super efficient. This may need to be generalized.

## Goal

Provide ergonomic asynchronous abstractions of all libuv functionality, at satisfactory performance.
Expand All @@ -52,7 +37,11 @@ access to concurrency; there is no `Task` or such. Awaiting a promise will save
execution state, and resume it as soon as the promise is ready. Currently, promises cannot
be properly cancelled; however, suspended coroutines can be cancelled - although the coroutine
they're waiting on will still run to completion (that's the downside of not having a `Task`
primitive).
primitive). `MultiPromise<T>` is very similar, but can be awaited repeatedly. This is more efficient
for streaming values between coroutines.

Coroutines are not run eagerly; you have to `co_await` them, or explicitly call
`schedule()` to make them run in the background.

When in doubt, refer to the examples in `test/`; they are actively maintained.

Expand Down

0 comments on commit bd9e575

Please sign in to comment.