You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/llarp/util/thread/logic.hpp

62 lines
947 B
C++

#ifndef LLARP_LOGIC_HPP
#define LLARP_LOGIC_HPP
#include <util/mem.h>
#include <util/thread/threadpool.h>
#include <util/thread/timer.hpp>
namespace llarp
{
class Logic
{
public:
struct llarp_threadpool* thread;
struct llarp_timer_context* timer;
std::optional< std::thread::id > id;
Logic();
~Logic();
/// single threaded tick
void
tick(llarp_time_t now);
/// isolated tick
void
tick_async(llarp_time_t now);
void
stop_timer();
void
stop();
void
mainloop();
void
queue_job(struct llarp_thread_job job);
bool
queue_func(std::function< void(void) >&& func);
uint32_t
call_later(const llarp_timeout_job& job);
void
call_later(llarp_time_t later, std::function< void(void) > func);
void
cancel_call(uint32_t id);
void
remove_call(uint32_t id);
bool
can_flush() const;
};
} // namespace llarp
#endif