Skip to content

Commit 64164b1

Browse files
author
Vytautas Astrauskas
committed
Improve comments.
1 parent ff5e35b commit 64164b1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/thread.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ impl ThreadId {
6161
}
6262
}
6363

64-
/// An identifier of a set of blocked threads.
64+
/// An identifier of a set of blocked threads. 0 is used to indicate the absence
65+
/// of a blockset identifier and, therefore, is not a valid identifier.
6566
#[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
6667
pub struct BlockSetId(NonZeroU32);
6768

@@ -116,8 +117,8 @@ pub struct Thread<'mir, 'tcx> {
116117
}
117118

118119
impl<'mir, 'tcx> Thread<'mir, 'tcx> {
119-
/// Check if the thread terminated. If yes, change the state to terminated
120-
/// and return `true`.
120+
/// Check if the thread is done executing (no more stack frames). If yes,
121+
/// change the state to terminated and return `true`.
121122
fn check_terminated(&mut self) -> bool {
122123
if self.state == ThreadState::Enabled {
123124
if self.stack.is_empty() {
@@ -174,6 +175,7 @@ impl<'mir, 'tcx> Default for ThreadManager<'mir, 'tcx> {
174175
let mut threads = IndexVec::new();
175176
// Create the main thread and add it to the list of threads.
176177
let mut main_thread = Thread::default();
178+
// The main thread can *not* be joined on.
177179
main_thread.join_status = ThreadJoinStatus::Detached;
178180
threads.push(main_thread);
179181
Self {
@@ -282,7 +284,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
282284
self.threads
283285
.iter()
284286
.all(|thread| thread.state != ThreadState::BlockedOnJoin(joined_thread_id)),
285-
"a joinable thread has threads waiting for its termination"
287+
"a joinable thread already has threads waiting for its termination"
286288
);
287289
// Mark the joined thread as being joined so that we detect if other
288290
// threads try to join it.
@@ -349,7 +351,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
349351
/// The currently implemented scheduling policy is the one that is commonly
350352
/// used in stateless model checkers such as Loom: run the active thread as
351353
/// long as we can and switch only when we have to (the active thread was
352-
/// blocked, terminated, or was explicitly asked to be preempted).
354+
/// blocked, terminated, or has explicitly asked to be preempted).
353355
fn schedule(&mut self) -> InterpResult<'tcx, SchedulingAction> {
354356
if self.threads[self.active_thread].check_terminated() {
355357
// Check if we need to unblock any threads.

0 commit comments

Comments
 (0)