2222
2323#include " IOController.hpp"
2424
25- #include " ../threading/ReactionTask.hpp"
26-
2725namespace NUClear {
2826namespace extension {
2927
@@ -169,9 +167,6 @@ namespace extension {
169167 // Start by rebuilding the list
170168 rebuild_list ();
171169
172- // Control handlers run on the IO pool at HIGH priority with Inline::NEVER so they are
173- // always queued to the IO pool rather than running on the emitting thread. Inline wake
174- // reactions registered after them only write to the notify pipe so ::poll() unblocks.
175170 on<Trigger<dsl::word::IOConfiguration>, Pool<IOPool>, Priority::HIGH , Inline::NEVER >().then (
176171 " Configure IO Reaction" ,
177172 [this ](const dsl::word::IOConfiguration& config) {
@@ -181,7 +176,6 @@ namespace extension {
181176 std::sort (tasks.begin (), tasks.end ());
182177 dirty.store (true , std::memory_order_release);
183178 });
184- on<Trigger<dsl::word::IOConfiguration>, Inline::ALWAYS >().then (" Configure IO bump" , [this ] { bump (); });
185179
186180 on<Trigger<dsl::word::IOFinished>, Pool<IOPool>, Priority::HIGH , Inline::NEVER >().then (" IO Finished" , [this ](const dsl::word::IOFinished& event) {
187181 auto task = std::find_if (tasks.begin (), tasks.end (), [&event](const Task& t) {
@@ -207,7 +201,6 @@ namespace extension {
207201 }
208202 }
209203 });
210- on<Trigger<dsl::word::IOFinished>, Inline::ALWAYS >().then (" IO Finished bump" , [this ] { bump (); });
211204
212205 on<Trigger<dsl::operation::Unbind<IO >>, Pool<IOPool>, Priority::HIGH , Inline::NEVER >().then (
213206 " Unbind IO Reaction" ,
@@ -222,22 +215,10 @@ namespace extension {
222215
223216 dirty.store (true , std::memory_order_release);
224217 });
225- on<Trigger<dsl::operation::Unbind<IO >>, Inline::ALWAYS >().then (" Unbind IO bump" , [this ] { bump (); });
226-
227- on<Shutdown, Pool<IOPool>, Priority::HIGH , Inline::NEVER >().then (" Shutdown IO Controller" , [this ] {
228- running.store (false , std::memory_order_release);
229- });
230- on<Shutdown, Inline::ALWAYS >().then (" Shutdown IO bump" , [this ] { bump (); });
231-
232- on<Startup, Pool<IOPool>, Priority::NORMAL , Inline::NEVER >().then (" IO Poll" , [this ] {
233- if (!running.load (std::memory_order_acquire)) {
234- return ;
235- }
236-
237- if (dirty.load (std::memory_order_acquire)) {
238- rebuild_list ();
239- }
240218
219+ register_shutdown_control ();
220+ register_inline_bump_reactions ();
221+ register_poll_loop ([this ] {
241222 if (::poll (watches.data (), nfds_t (watches.size ()), -1 ) < 0 ) {
242223 throw std::system_error (network_errno,
243224 std::system_category (),
@@ -249,8 +230,6 @@ namespace extension {
249230 process_event (fd);
250231 }
251232 }
252-
253- powerplant.submit (threading::ReactionTask::get_current_task ()->parent ->get_task ());
254233 });
255234 }
256235
0 commit comments