This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/BigBaseV2/src/script.hpp

26 lines
544 B
C++
Raw Normal View History

2019-03-21 20:18:31 +01:00
#pragma once
#include "common.hpp"
namespace big
{
class script
{
public:
using func_t = void(*)();
public:
explicit script(func_t func, std::optional<std::size_t> stack_size = std::nullopt);
~script();
void tick();
void yield(std::optional<std::chrono::high_resolution_clock::duration> time = std::nullopt);
static script *get_current();
private:
void fiber_func();
private:
void *m_script_fiber;
void *m_main_fiber;
func_t m_func;
std::optional<std::chrono::high_resolution_clock::time_point> m_wake_time;
};
}