2018-11-19 23:57:28 +00:00
|
|
|
#ifndef LLARP_LOGIC_HPP
|
|
|
|
#define LLARP_LOGIC_HPP
|
2018-05-20 16:15:16 +00:00
|
|
|
#include <llarp/mem.h>
|
2018-04-30 18:18:18 +00:00
|
|
|
#include <llarp/threadpool.h>
|
2018-11-19 22:45:37 +00:00
|
|
|
#include <llarp/timer.hpp>
|
2018-04-30 18:18:18 +00:00
|
|
|
|
2018-12-10 14:14:55 +00:00
|
|
|
namespace llarp
|
2018-07-09 04:26:27 +00:00
|
|
|
{
|
2018-12-10 14:14:55 +00:00
|
|
|
class Logic
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
struct llarp_threadpool* thread;
|
|
|
|
struct llarp_timer_context* timer;
|
2018-04-30 18:18:18 +00:00
|
|
|
|
2018-12-10 14:14:55 +00:00
|
|
|
public:
|
|
|
|
Logic()
|
|
|
|
: thread(llarp_init_same_process_threadpool())
|
|
|
|
, timer(llarp_init_timer())
|
|
|
|
{
|
|
|
|
}
|
2018-04-30 18:18:18 +00:00
|
|
|
|
2018-12-10 14:14:55 +00:00
|
|
|
Logic(struct llarp_threadpool* tp) : thread(tp), timer(llarp_init_timer())
|
|
|
|
{
|
|
|
|
}
|
2018-06-06 12:46:26 +00:00
|
|
|
|
2018-12-10 14:14:55 +00:00
|
|
|
/// single threaded tick
|
|
|
|
void
|
|
|
|
tick(llarp_time_t now);
|
2018-06-06 12:46:26 +00:00
|
|
|
|
2018-12-10 14:14:55 +00:00
|
|
|
/// isolated tick
|
|
|
|
void
|
|
|
|
tick_async(llarp_time_t now);
|
2018-08-09 19:02:17 +00:00
|
|
|
|
2018-12-10 14:14:55 +00:00
|
|
|
void
|
|
|
|
stop_timer();
|
2018-04-30 18:18:18 +00:00
|
|
|
|
2018-12-10 14:14:55 +00:00
|
|
|
void
|
|
|
|
stop();
|
2018-04-30 18:18:18 +00:00
|
|
|
|
2018-12-10 14:14:55 +00:00
|
|
|
void
|
|
|
|
mainloop();
|
2018-08-09 19:02:17 +00:00
|
|
|
|
2018-12-10 14:14:55 +00:00
|
|
|
void
|
|
|
|
queue_job(struct llarp_thread_job job);
|
2018-04-30 18:18:18 +00:00
|
|
|
|
2018-12-10 14:14:55 +00:00
|
|
|
uint32_t
|
|
|
|
call_later(struct llarp_timeout_job job);
|
2018-05-27 12:49:10 +00:00
|
|
|
|
2018-12-10 14:14:55 +00:00
|
|
|
void
|
|
|
|
cancel_call(uint32_t id);
|
2018-07-03 11:25:36 +00:00
|
|
|
|
2018-12-10 14:14:55 +00:00
|
|
|
void
|
|
|
|
remove_call(uint32_t id);
|
|
|
|
};
|
|
|
|
} // namespace llarp
|
2018-04-30 18:18:18 +00:00
|
|
|
|
|
|
|
#endif
|