diff --git a/Assignment/Task 3/fiber.h b/Assignment/Task 3/fiber.h new file mode 100644 index 0000000000000000000000000000000000000000..7ba411000ffbecdc16a6e31ceacc8f494ccf7989 --- /dev/null +++ b/Assignment/Task 3/fiber.h @@ -0,0 +1,31 @@ +#ifndef FIBER_H +#define FIBER_H + +#include <array> +#include "context.h" + +class fiber { +private: + Context context_; + std::array<char, 4096> stack_; + char* stack_bottom_; + char* stack_top_; + void* data_; + bool is_finished; + +public: + fiber(void (*function)(void*), void* data); + ~fiber(); + + Context* get_context(); + void* get_data() const; + void yield(); + void finish() { + is_finished = true; + } + bool finished() const{ + return is_finished;} +}; + +#endif // FIBER_H +