Skip to content

Commit 820c38e

Browse files
committed
Rename Active / Dead to better reflect their behavior
1 parent b458f91 commit 820c38e

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/lua.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -765,15 +765,14 @@ impl<'lua> Function<'lua> {
765765
/// Status of a Lua thread (or coroutine).
766766
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
767767
pub enum ThreadStatus {
768-
/// The thread has finished executing.
769-
Dead,
770-
/// The thread was just created, is currently running or is suspended because it has called
771-
/// `coroutine.yield`.
768+
/// The thread was just created, or is suspended because it has called `coroutine.yield`.
772769
///
773770
/// If a thread is in this state, it can be resumed by calling [`Thread::resume`].
774771
///
775772
/// [`Thread::resume`]: struct.Thread.html#method.resume
776-
Active,
773+
Resumable,
774+
/// Either the thread has finished executing, or the thread is currently running.
775+
Unresumable,
777776
/// The thread has raised a Lua error during execution.
778777
Error,
779778
}
@@ -886,9 +885,9 @@ impl<'lua> Thread<'lua> {
886885
if status != ffi::LUA_OK && status != ffi::LUA_YIELD {
887886
ThreadStatus::Error
888887
} else if status == ffi::LUA_YIELD || ffi::lua_gettop(thread_state) > 0 {
889-
ThreadStatus::Active
888+
ThreadStatus::Resumable
890889
} else {
891-
ThreadStatus::Dead
890+
ThreadStatus::Unresumable
892891
}
893892
})
894893
}

src/tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -599,17 +599,17 @@ fn test_thread() {
599599
).unwrap(),
600600
);
601601

602-
assert_eq!(thread.status(), ThreadStatus::Active);
602+
assert_eq!(thread.status(), ThreadStatus::Resumable);
603603
assert_eq!(thread.resume::<_, i64>(0).unwrap(), 0);
604-
assert_eq!(thread.status(), ThreadStatus::Active);
604+
assert_eq!(thread.status(), ThreadStatus::Resumable);
605605
assert_eq!(thread.resume::<_, i64>(1).unwrap(), 1);
606-
assert_eq!(thread.status(), ThreadStatus::Active);
606+
assert_eq!(thread.status(), ThreadStatus::Resumable);
607607
assert_eq!(thread.resume::<_, i64>(2).unwrap(), 3);
608-
assert_eq!(thread.status(), ThreadStatus::Active);
608+
assert_eq!(thread.status(), ThreadStatus::Resumable);
609609
assert_eq!(thread.resume::<_, i64>(3).unwrap(), 6);
610-
assert_eq!(thread.status(), ThreadStatus::Active);
610+
assert_eq!(thread.status(), ThreadStatus::Resumable);
611611
assert_eq!(thread.resume::<_, i64>(4).unwrap(), 10);
612-
assert_eq!(thread.status(), ThreadStatus::Dead);
612+
assert_eq!(thread.status(), ThreadStatus::Unresumable);
613613

614614
let accumulate = lua.create_thread(
615615
lua.eval::<Function>(
@@ -628,7 +628,7 @@ fn test_thread() {
628628
accumulate.resume::<_, ()>(i).unwrap();
629629
}
630630
assert_eq!(accumulate.resume::<_, i64>(4).unwrap(), 10);
631-
assert_eq!(accumulate.status(), ThreadStatus::Active);
631+
assert_eq!(accumulate.status(), ThreadStatus::Resumable);
632632
assert!(accumulate.resume::<_, ()>("error").is_err());
633633
assert_eq!(accumulate.status(), ThreadStatus::Error);
634634

@@ -642,7 +642,7 @@ fn test_thread() {
642642
"#,
643643
None,
644644
).unwrap();
645-
assert_eq!(thread.status(), ThreadStatus::Active);
645+
assert_eq!(thread.status(), ThreadStatus::Resumable);
646646
assert_eq!(thread.resume::<_, i64>(()).unwrap(), 42);
647647

648648
let thread: Thread = lua.eval(

0 commit comments

Comments
 (0)