123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- #pragma once
- #include "rotor/arc.hpp"
- #include "rotor/system_context.h"
- #include "rotor/timer_handler.hpp"
- #include "rotor/thread/export.h"
- #include <chrono>
- #include <condition_variable>
- #include <list>
- #include <mutex>
- #include <thread>
- #if defined(_MSC_VER)
- #pragma warning(push)
- #pragma warning(disable : 4251)
- #endif
- namespace rotor {
- namespace thread {
- struct supervisor_thread_t;
- using supervisor_ptr_t = intrusive_ptr_t<supervisor_thread_t>;
- struct ROTOR_THREAD_API system_context_thread_t : public system_context_t {
-
- system_context_thread_t() noexcept;
-
- virtual void run() noexcept;
-
- void check() noexcept;
- protected:
-
- using clock_t = std::chrono::steady_clock;
-
- struct deadline_info_t {
-
- timer_handler_base_t *handler;
-
- clock_t::time_point deadline;
- };
-
- using list_t = std::list<deadline_info_t>;
-
- void update_time() noexcept;
-
- void start_timer(const pt::time_duration &interval, timer_handler_base_t &handler) noexcept;
-
- void cancel_timer(request_id_t timer_id) noexcept;
-
- std::mutex mutex;
-
- std::condition_variable cv;
-
- clock_t::time_point now;
-
- list_t timer_nodes;
-
- bool intercepting = false;
- friend struct supervisor_thread_t;
- };
- using system_context_ptr_t = rotor::intrusive_ptr_t<system_context_thread_t>;
- }
- }
- #if defined(_MSC_VER)
- #pragma warning(pop)
- #endif
|