Rework scheduler to store the current thread separately.
This works better with the sleep thread and lets us check state transitions more easily.
This commit is contained in:
parent
656687b183
commit
3fee5ac9d7
2 changed files with 46 additions and 27 deletions
|
|
@ -44,16 +44,22 @@ class LinkedList {
|
|||
return ret;
|
||||
}
|
||||
|
||||
T CycleFront() {
|
||||
/*
|
||||
* Returns the front item in the list and pushes the passed item to the back.
|
||||
*
|
||||
* Done in one function to avoid a memory alloc/dealloc during scheduling.
|
||||
**/
|
||||
T CycleFront(const T& new_item) {
|
||||
if (size_ == 0 || front_ == nullptr) {
|
||||
panic("Cycling empty list");
|
||||
}
|
||||
|
||||
T ret = front_->item;
|
||||
front_->item = new_item;
|
||||
if (size_ == 1) {
|
||||
return front_->item;
|
||||
return ret;
|
||||
}
|
||||
|
||||
T ret = front_->item;
|
||||
ListItem* old_front = front_;
|
||||
ListItem* iter = front_;
|
||||
front_ = front_->next;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue