Skip to content

Commit

Permalink
Kernel: Remove old block(State) API
Browse files Browse the repository at this point in the history
New API should be used always :)
  • Loading branch information
rburchell authored and awesomekling committed Jul 19, 2019
1 parent 762333b commit 99c5377
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Kernel/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ void Thread::unblock()
void Thread::block_until(const char* state_string, Function<bool()>&& condition)
{
m_blocker = make<ConditionBlocker>(state_string, condition);
block(Thread::Blocked);
block_helper();
Scheduler::yield();
}

void Thread::block(Thread::State new_state)
void Thread::block_helper()
{
bool did_unlock = process().big_lock().unlock_if_locked();
ASSERT(state() == Thread::Running);
m_was_interrupted_while_blocked = false;
set_state(new_state);
set_state(Thread::Blocked);
Scheduler::yield();
if (did_unlock)
process().big_lock().lock();
Expand All @@ -129,7 +129,7 @@ void Thread::block(Thread::State new_state)
void Thread::block(Blocker& blocker)
{
m_blocker = &blocker;
block(Thread::Blocked);
block_helper();
}

u64 Thread::sleep(u32 ticks)
Expand Down
3 changes: 2 additions & 1 deletion Kernel/Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ class Thread : public InlineLinkedListNode<Thread> {
u32 ticks() const { return m_ticks; }

u64 sleep(u32 ticks);
void block(Thread::State);
void block(Blocker& blocker);
void unblock();

Expand Down Expand Up @@ -299,6 +298,8 @@ class Thread : public InlineLinkedListNode<Thread> {
State m_state { Invalid };
bool m_has_used_fpu { false };
bool m_was_interrupted_while_blocked { false };

void block_helper();
};

HashTable<Thread*>& thread_table();
Expand Down

0 comments on commit 99c5377

Please sign in to comment.