Skip to content

Commit

Permalink
fix(windows): Fixed some thread safety problems.
Browse files Browse the repository at this point in the history
Fix #78.
  • Loading branch information
Skyost committed Jan 4, 2024
1 parent 421fe69 commit 28ff2a4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/bonsoir_windows/windows/bonsoir_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ namespace bonsoir_windows {
std::make_unique<StreamHandlerFunctions<EncodableValue>>(
[this](const EncodableValue *arguments, std::unique_ptr<EventSink<EncodableValue>> &&events)
-> std::unique_ptr<StreamHandlerError<EncodableValue>> {
std::unique_lock<std::mutex> _ul(mutex);
eventSink = std::move(events);
processEventQueue();
return nullptr;
},
[this](const EncodableValue *arguments)
-> std::unique_ptr<StreamHandlerError<EncodableValue>> {
std::unique_lock<std::mutex> _ul(mutex);
eventSink.release();
eventSink = nullptr;
return nullptr;
Expand Down Expand Up @@ -88,6 +86,7 @@ namespace bonsoir_windows {
if (!eventSink) {
return;
}
std::scoped_lock lock{mutex};
while (!eventQueue.empty()) {
eventQueue.front()->process(this);
eventQueue.pop();
Expand Down

0 comments on commit 28ff2a4

Please sign in to comment.