2018-04-30 18:18:18 +00:00
|
|
|
#ifndef LLARP_LOGIC_H
|
|
|
|
#define LLARP_LOGIC_H
|
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-07-09 04:26:27 +00:00
|
|
|
struct llarp_logic
|
|
|
|
{
|
|
|
|
struct llarp_threadpool* thread;
|
|
|
|
struct llarp_timer_context* timer;
|
|
|
|
};
|
2018-04-30 18:18:18 +00:00
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
struct llarp_logic*
|
2018-05-28 13:49:44 +00:00
|
|
|
llarp_init_logic();
|
2018-04-30 18:18:18 +00:00
|
|
|
|
2018-06-06 12:46:26 +00:00
|
|
|
/// single threaded mode logic event loop
|
|
|
|
struct llarp_logic*
|
|
|
|
llarp_init_single_process_logic(struct llarp_threadpool* tp);
|
|
|
|
|
|
|
|
/// single threaded tick
|
|
|
|
void
|
2018-10-29 16:48:36 +00:00
|
|
|
llarp_logic_tick(struct llarp_logic* logic, llarp_time_t now);
|
2018-06-06 12:46:26 +00:00
|
|
|
|
2018-08-09 19:02:17 +00:00
|
|
|
/// isolated tick
|
|
|
|
void
|
2018-10-29 16:48:36 +00:00
|
|
|
llarp_logic_tick_async(struct llarp_logic* logic, llarp_time_t now);
|
2018-08-09 19:02:17 +00:00
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
void
|
|
|
|
llarp_free_logic(struct llarp_logic** logic);
|
2018-04-30 18:18:18 +00:00
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
void
|
|
|
|
llarp_logic_queue_job(struct llarp_logic* logic, struct llarp_thread_job job);
|
2018-04-30 18:18:18 +00:00
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
uint32_t
|
|
|
|
llarp_logic_call_later(struct llarp_logic* logic, struct llarp_timeout_job job);
|
2018-08-09 19:02:17 +00:00
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
void
|
|
|
|
llarp_logic_cancel_call(struct llarp_logic* logic, uint32_t id);
|
2018-04-30 18:18:18 +00:00
|
|
|
|
2018-05-27 12:49:10 +00:00
|
|
|
void
|
|
|
|
llarp_logic_remove_call(struct llarp_logic* logic, uint32_t id);
|
|
|
|
|
2018-07-03 11:25:36 +00:00
|
|
|
void
|
|
|
|
llarp_logic_stop_timer(struct llarp_logic* logic);
|
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
void
|
|
|
|
llarp_logic_stop(struct llarp_logic* logic);
|
2018-04-30 18:18:34 +00:00
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
void
|
|
|
|
llarp_logic_mainloop(struct llarp_logic* logic);
|
2018-04-30 18:18:18 +00:00
|
|
|
|
|
|
|
#endif
|