1#ifndef LIPH_COROUTINE_H_
2#define LIPH_COROUTINE_H_
23 static const size_t STACKSIZE = 1024 * 1024;
26 int add(std::shared_ptr<coroutine> co);
29 int status(
int id)
const;
32 static void run(processor *p);
35 char stack_[STACKSIZE];
38 std::vector<std::shared_ptr<coroutine> > co_list_;
43 enum { DEAD = 0, READY = 1, RUNNING = 2, SUSPEND = 3 };
45 friend class processor;
48 coroutine(std::function<
void(
void *)> entry,
void *user_data) : entry_(entry), user_data_(user_data) {}
50 int status()
const {
return status_; }
53 void save_stack(
char *top);
56 std::function<void(
void *)> entry_;
57 void *user_data_{
nullptr};
62 char *stack_{
nullptr};
Definition: algorithm.h:10