worker: use rwlock for sibling group · nodejs/node@a2da9e2 · GitHub
Skip to content

Commit a2da9e2

Browse files
addaleaxdanielleadams
authored andcommitted
worker: use rwlock for sibling group
Since it is much more common to send messages than to add or remove ports from a sibling group, using a rwlock is appropriate here. Refs: #38780 (comment) PR-URL: #38783 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 3e6b3b2 commit a2da9e2

3 files changed

Lines changed: 81 additions & 5 deletions

File tree

src/node_messaging.cc

Lines changed: 3 additions & 3 deletions

src/node_messaging.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ class SiblingGroup final : public std::enable_shared_from_this<SiblingGroup> {
150150
size_t size() const { return ports_.size(); }
151151

152152
private:
153-
std::string name_;
153+
const std::string name_;
154+
RwLock group_mutex_; // Protects ports_.
154155
std::set<MessagePortData*> ports_;
155-
Mutex group_mutex_;
156156

157157
static void CheckSiblingGroup(const std::string& name);
158158

src/node_mutex.h

Lines changed: 76 additions & 0 deletions

0 commit comments

Comments
 (0)