Skip to content

Commit

Permalink
fix data race (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLartians authored Apr 24, 2020
1 parent 1fe1f18 commit c8a7c3e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/observe/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ namespace observe {
*/
void emit(Args... args) const {
std::vector<std::weak_ptr<Handler>> handlers;
handlers.resize(data->observers.size());
{
std::lock_guard<std::mutex> lock(data->observerMutex);
handlers.resize(data->observers.size());
std::transform(data->observers.begin(), data->observers.end(), handlers.begin(),
[](auto &h) { return h.callback; });
}
Expand Down

0 comments on commit c8a7c3e

Please sign in to comment.