diff options
Diffstat (limited to 'modules/thread')
-rw-r--r-- | modules/thread/c++/remote.hpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/modules/thread/c++/remote.hpp b/modules/thread/c++/remote.hpp new file mode 100644 index 0000000..83dca4c --- /dev/null +++ b/modules/thread/c++/remote.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include <thread> + +namespace saw { +namespace rmt { +struct Thread {}; +} + +template<> +class device<rmt::Thread> final { +private: + event_loop ev_loop_; + std::thread thread_; + bool keep_running_; + + void run(){ + wait_scope wait{ev_loop_}; + + while(keep_running_){ + wait.wait(std::chrono::seconds{4u}); + } + } +public: + device(): + ev_loop_{}, + thread_{&device<rmt::Thread>::run, this}, + keep_running_{true} + { + } +}; + +template<> +class remote<rmt::Thread> final { + private: +public: + remote() = default; + + conveyor<own<remote_address<rmt::Thread>>> resolve_address(){ + return heap<remote_address<rmt::Thread>>(*this); + } + + device<rmt::Thread> connect_device(const remote_address<rmt::Thread>& ){ + return {}; + } +}; +} |