Skip to content

Commit d0de439

Browse files
Vytautas Astrauskasvakaras
authored andcommitted
Cleanup.
1 parent 6792457 commit d0de439

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

src/thread.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::cell::RefCell;
44
use std::collections::hash_map::Entry;
55
use std::convert::TryFrom;
6-
use std::num::{NonZeroU32, TryFromIntError};
6+
use std::num::TryFromIntError;
77
use std::time::Instant;
88

99
use log::trace;
@@ -77,21 +77,6 @@ impl ThreadId {
7777
}
7878
}
7979

80-
/// An identifier of a set of blocked threads. 0 is used to indicate the absence
81-
/// of a blockset identifier and, therefore, is not a valid identifier.
82-
#[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
83-
pub struct BlockSetId(NonZeroU32);
84-
85-
impl BlockSetId {
86-
/// Panics if `id` is 0.
87-
pub fn new(id: u32) -> Self {
88-
Self(NonZeroU32::new(id).expect("0 is not a valid blockset id"))
89-
}
90-
pub fn to_u32_scalar<'tcx>(&self) -> Scalar<Tag> {
91-
Scalar::from_u32(self.0.get())
92-
}
93-
}
94-
9580
/// The state of a thread.
9681
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
9782
pub enum ThreadState {
@@ -100,9 +85,10 @@ pub enum ThreadState {
10085
/// The thread tried to join the specified thread and is blocked until that
10186
/// thread terminates.
10287
BlockedOnJoin(ThreadId),
103-
/// The thread is blocked and belongs to the given blockset.
104-
Blocked(BlockSetId),
105-
BlockedThread,
88+
/// The thread is blocked on some synchronization primitive. It is the
89+
/// responsibility of the synchronization primitives to track threads that
90+
/// are blocked by them.
91+
BlockedOnSync,
10692
/// The thread has terminated its execution (we do not delete terminated
10793
/// threads).
10894
Terminated,
@@ -357,13 +343,13 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
357343
fn block_thread(&mut self, thread: ThreadId) {
358344
let state = &mut self.threads[thread].state;
359345
assert_eq!(*state, ThreadState::Enabled);
360-
*state = ThreadState::BlockedThread;
346+
*state = ThreadState::BlockedOnSync;
361347
}
362348

363349
/// Put the blocked thread into the enabled state.
364350
fn unblock_thread(&mut self, thread: ThreadId) {
365351
let state = &mut self.threads[thread].state;
366-
assert_eq!(*state, ThreadState::BlockedThread);
352+
assert_eq!(*state, ThreadState::BlockedOnSync);
367353
*state = ThreadState::Enabled;
368354
}
369355

0 commit comments

Comments
 (0)