Ejemplo n.º 1
0
void yield(scheduler& target, task_t next) {
    scheduler::node self;
    auto old = callcc(
        std::move(next),
        [&](task_t task) {
            self.task = std::move(task);
            target.push(&self);
            return task;
        });
    assert(!old);
}
Ejemplo n.º 2
0
void details::scheduler_waiter::wait(std::uint32_t count) {
    auto to = callcc
        (details::scheduler_pop(),
         [&](task_t c) {
            task = std::move(c);
            if ((signal_counter += count) <= 0)
                details::scheduler_post(*this);
            return c;
        });
    assert(!to);
}
Ejemplo n.º 3
0
void idle(scheduler& sched) {
    scheduler_saver _ (sched);

    auto next = sched.pop();
    if (next == 0) {
        sched.waiting.exchange(true);
        sched.waiter.reset();
        while ((next = sched.pop()) == 0)
            sched.waiter.wait();
        sched.waiting.store(0, std::memory_order_relaxed);
    }

    scheduler::node self;
    auto old = callcc(
        std::move(next->task),
        [&](task_t task) {
            self.task = std::move(task);
            sched.push(&self);
            return task;
        });
    assert(!old);
}
Ejemplo n.º 4
0
int is_valid(void* _ptr) {
    ptr = _ptr;
    signal(SIGSEGV, pf_handler);
    return callcc(is_valid_handler);
}