1.1 --- a/pkg/devices/util/include/event-loop.h Fri May 18 23:41:51 2018 +0200
1.2 +++ b/pkg/devices/util/include/event-loop.h Sat May 19 00:58:00 2018 +0200
1.3 @@ -93,4 +93,38 @@
1.4 }
1.5 };
1.6
1.7 +/* Event loop with handler and null event type. */
1.8 +
1.9 +template <>
1.10 +class Event_handler_loop<void> : public Event_loop
1.11 +{
1.12 +protected:
1.13 + /* Event type. */
1.14 +
1.15 + typedef void Event_type;
1.16 +
1.17 + /* Handler function type. */
1.18 +
1.19 + typedef void (*Event_handler)();
1.20 +
1.21 + /* External handler function. */
1.22 +
1.23 + Event_handler _handler;
1.24 +
1.25 +public:
1.26 + /* Initialise the event loop with a thread priority. */
1.27 +
1.28 + explicit Event_handler_loop(int priority=0x20)
1.29 + : Event_loop(priority)
1.30 + {
1.31 + }
1.32 +
1.33 + /* Attach a handler to the loop. */
1.34 +
1.35 + virtual void attach(Event_handler handler)
1.36 + {
1.37 + _handler = handler;
1.38 + }
1.39 +};
1.40 +
1.41 #endif