-
-
Notifications
You must be signed in to change notification settings - Fork 37.2k
[Proposal] - Thead Safe data structures #55568
Copy link
Copy link
Closed as not planned
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.workerIssues and PRs related to the worker_threads module and Worker API.Issues and PRs related to the worker_threads module and Worker API.
Description
Activity
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.workerIssues and PRs related to the worker_threads module and Worker API.Issues and PRs related to the worker_threads module and Worker API.
Type
Projects
- StatusShow more project fieldsAwaiting Triage
What is the problem this feature will solve?
What I'd like to achieve is an implementation of shared (between worker threads) and thread safe data structures.
I want something easier to work with when doing multithread nodejs. Sharing data between threads using SharedArrayBuffer can be hard sometimes.
What is the feature you are proposing to solve the problem?
I'll show you an example of what the API usage could look like for a data structure like LRU Cache:
This is the code in the main thread
this is the worker code:
I started working into an implementation that uses extensively SharedArrayBuffer and Atomics to reach thread safety but there are lots of problems to take into consideration like:
Do you guys think it's a useful feature and worth implementing or taking it into consideration?
What alternatives have you considered?
No response