3
3
use std:: cell:: RefCell ;
4
4
use std:: collections:: hash_map:: Entry ;
5
5
use std:: convert:: TryFrom ;
6
- use std:: num:: { NonZeroU32 , TryFromIntError } ;
6
+ use std:: num:: TryFromIntError ;
7
7
use std:: time:: Instant ;
8
8
9
9
use log:: trace;
@@ -77,21 +77,6 @@ impl ThreadId {
77
77
}
78
78
}
79
79
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
-
95
80
/// The state of a thread.
96
81
#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
97
82
pub enum ThreadState {
@@ -100,9 +85,10 @@ pub enum ThreadState {
100
85
/// The thread tried to join the specified thread and is blocked until that
101
86
/// thread terminates.
102
87
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 ,
106
92
/// The thread has terminated its execution (we do not delete terminated
107
93
/// threads).
108
94
Terminated ,
@@ -357,13 +343,13 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
357
343
fn block_thread ( & mut self , thread : ThreadId ) {
358
344
let state = & mut self . threads [ thread] . state ;
359
345
assert_eq ! ( * state, ThreadState :: Enabled ) ;
360
- * state = ThreadState :: BlockedThread ;
346
+ * state = ThreadState :: BlockedOnSync ;
361
347
}
362
348
363
349
/// Put the blocked thread into the enabled state.
364
350
fn unblock_thread ( & mut self , thread : ThreadId ) {
365
351
let state = & mut self . threads [ thread] . state ;
366
- assert_eq ! ( * state, ThreadState :: BlockedThread ) ;
352
+ assert_eq ! ( * state, ThreadState :: BlockedOnSync ) ;
367
353
* state = ThreadState :: Enabled ;
368
354
}
369
355
0 commit comments