mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 16:48:37 +00:00
submit_frame_test: the contended lock is taken and released on its holder's thread
Unlocking a mutex on another thread is undefined; MSVC's runtime throws, and under Wine the test stopped on msvcp140's missing _Throw_Cpp_error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -59,11 +59,13 @@ int scripted() {
|
||||
EXPECT(fences > 1 * ms && double(fences) <= call_ns - 1e6);
|
||||
// A lock another thread holds for 4 ms: counted as a lock wait, inside the other parts (not in the frame's sum).
|
||||
std::mutex m;
|
||||
std::unique_lock held(m);
|
||||
std::thread holder([&] {
|
||||
std::atomic<bool> taken{false};
|
||||
std::thread holder([&] { // takes the lock and lets it go on its own thread, as a mutex must be
|
||||
const std::lock_guard held(m);
|
||||
taken.store(true);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(4));
|
||||
held.unlock();
|
||||
});
|
||||
while (!taken.load()) std::this_thread::yield();
|
||||
{
|
||||
std::unique_lock lock(m, std::defer_lock);
|
||||
sp::lock_timed(lock);
|
||||
|
||||
Reference in New Issue
Block a user