Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[seraphis] async: add async framework #9337

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

UkoeHB
Copy link
Contributor

@UkoeHB UkoeHB commented May 20, 2024

This is a PR in my 'upstreaming seraphis_lib project', the changes here are not used anywhere yet.

Depends on:

Adds an async framework.

async::Threadpool

Adds a threadpool modeled after Sean Parent's threadpool. A reference implementation of Parent's threadpool is included under the parent namespace. Here is a lecture from Parent talking about concurrency.

Features:

  • Multiple workstealing queues.
  • Task priorities.
  • 'Fanout' capability for adding temporary workers when another worker is blocked on I/O.
  • Versatile split/join functionality. The WaiterManager handles this internally.
  • Simple and 'sleepy' task types. A sleepy task will sleep for a pre-defined duration (or until a pre-defined time) before running.
  • Tasks can return their continuation (i.e. the task that should run after the task is complete, which is e.g. useful for running task loops without causing stack overflow when running single-threaded).
  • Responsive shut-down mechanisms.

This threadpool is used in @j-berman's async scanner.

Single-writer/multi-reader data structure

Adds a thread-safe tool for read/write access to data. You can use writable/readable handles to get write_locks and read_locks.

One use-case here is in responsive balance recovery. You can pass a writable<EnoteStore> to the balance recovery machinery, and then continuously emit enote store events along with readable<EnoteStore> handles to wallet code. The wallet code can acquire read_locks on the store to update its user-facing data structures based on the events that occur.

Mutex

Adds a mutex wrapper that lets you validate that the current thread owns a lock. Used in the async scanner for checking synchronization invariants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants