Skip to content

Commit

Permalink
Fix missing lock guard (#130)
Browse files Browse the repository at this point in the history
This commit fixes a bug where the lock guard (for concurrently accessing
the same scope from different threads) had basically no effect, due to
being bound to a temporary only.
  • Loading branch information
NewProggie authored Mar 16, 2020
1 parent 06e4871 commit eaa7d5b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion example/threads.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ auto callback(
void* env, const wasm::Val args[], wasm::Val results[]
) -> wasm::own<wasm::Trap> {
assert(args[0].kind() == wasm::ValKind::I32);
std::lock_guard<std::mutex>(*reinterpret_cast<std::mutex*>(env));
std::lock_guard<std::mutex> lock(*reinterpret_cast<std::mutex*>(env));
std::cout << "Thread " << args[0].i32() << " running..." << std::endl;
std::cout.flush();
return nullptr;
Expand Down

0 comments on commit eaa7d5b

Please sign in to comment.