Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/auto-ready-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr merge "${{ github.event.pull_request.html_url }}" --auto --merge
gh pr merge "${{ github.event.pull_request.html_url }}" --auto --merge || true
27 changes: 27 additions & 0 deletions stdlib/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,31 @@ mod tests {
let guard = mutex.locked.lock().unwrap();
assert_eq!(*guard, false);
}

#[test]
fn test_script_mutex_unlock() {
use std::sync::Arc;
use std::thread;
use std::time::Duration;

let mutex = Arc::new(ScriptMutex::new());
mutex.lock();

let mutex_clone = Arc::clone(&mutex);
let handle = thread::spawn(move || {
// This will block until the main thread unlocks it.
mutex_clone.lock();
// Now unlock it so the test can finish cleanly
mutex_clone.unlock();
});

// Give the spawned thread a moment to block on the mutex.
thread::sleep(Duration::from_millis(50));

// Unlock, which should wake the sleeping thread.
mutex.unlock();

// If unlock() doesn't work, this join will hang indefinitely.
handle.join().unwrap();
}
}