in source/thread_unsafe_event_loop.cpp [43:69]
void thread_unsafe_event_loop::enqueue(operation_base* op) noexcept {
auto* current = head_;
if (current == nullptr || op->dueTime_ < current->dueTime_) {
// insert at head of list
head_ = op;
op->prevPtr_ = &head_;
op->next_ = current;
if (current != nullptr) {
current->prevPtr_ = &op->next_;
}
} else {
// Traverse the list until we find the item we should
// be inserted after.
while (current->next_ != nullptr &&
current->next_->dueTime_ <= op->dueTime_) {
current = current->next_;
}
// Insert after 'current'
op->next_ = current->next_;
if (op->next_ != nullptr) {
op->next_->prevPtr_ = &op->next_;
}
op->prevPtr_ = ¤t->next_;
current->next_ = op;
}
}