From 73b463cdbb6d8aeb89eff8fa371f519d493e91bf Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 20 Apr 2016 23:22:12 +0200 Subject: [PATCH] Signal_handler: remove num argument from handler We will eventually remove the delivery of the number of occurred signals to the recipient. There haven't been any convincing use cases for this feature. In the contrary, it actually led to wrong design choices in the past where the rate of signals carried information (such as the progress of time) that should better be obtained via an explicit RPC call. The old 'Signal_rpc_member' template retains the old interface for now. But the new 'Signal_handler' omits the 'unsigned' argument from the handler function. --- repos/base/include/base/entrypoint.h | 2 +- repos/base/include/base/signal.h | 12 +++-- repos/os/include/os/signal_rpc_dispatcher.h | 50 ++++++++++++++++++--- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/repos/base/include/base/entrypoint.h b/repos/base/include/base/entrypoint.h index b270edac3e..cbb0044343 100644 --- a/repos/base/include/base/entrypoint.h +++ b/repos/base/include/base/entrypoint.h @@ -85,7 +85,7 @@ class Genode::Entrypoint : Genode::Noncopyable * let the signal-dispatching thread execute the actual suspend- * resume mechanism. */ - void _handle_suspend(unsigned) { } + void _handle_suspend() { } Lazy_volatile_object> _suspend_dispatcher; void _dispatch_signal(Signal &sig); diff --git a/repos/base/include/base/signal.h b/repos/base/include/base/signal.h index eedc6ce88a..ff3dbe51ea 100644 --- a/repos/base/include/base/signal.h +++ b/repos/base/include/base/signal.h @@ -438,12 +438,10 @@ class Genode::Signal_dispatcher : public Signal_dispatcher_base, /** * Signal dispatcher for handling signals by an object method * - * This utility associates object methods with signals. It is intended to + * This utility associates an object method with signals. It is intended to * be used as a member variable of the class that handles incoming signals * of a certain type. The constructor takes a pointer-to-member to the - * signal-handling method as argument. If a signal is received at the - * common signal reception code, this method will be invoked by calling - * 'Signal_dispatcher_base::dispatch'. + * signal-handling method as argument. * * \param T type of signal-handling class * \param EP type of entrypoint handling signal RPC @@ -454,7 +452,7 @@ struct Genode::Signal_handler : Genode::Signal_dispatcher_base, { EP &ep; T &obj; - void (T::*member) (unsigned); + void (T::*member) (); /** * Constructor @@ -463,7 +461,7 @@ struct Genode::Signal_handler : Genode::Signal_dispatcher_base, * \param obj,member object and method to call when * the signal occurs */ - Signal_handler(EP &ep, T &obj, void (T::*member)(unsigned)) + Signal_handler(EP &ep, T &obj, void (T::*member)()) : Signal_context_capability(ep.manage(*this)), ep(ep), obj(obj), member(member) { } @@ -472,7 +470,7 @@ struct Genode::Signal_handler : Genode::Signal_dispatcher_base, /** * Interface of Signal_dispatcher_base */ - void dispatch(unsigned num) { (obj.*member)(num); } + void dispatch(unsigned num) { (obj.*member)(); } }; #endif /* _INCLUDE__BASE__SIGNAL_H_ */ diff --git a/repos/os/include/os/signal_rpc_dispatcher.h b/repos/os/include/os/signal_rpc_dispatcher.h index 23b429c690..cda4d26358 100644 --- a/repos/os/include/os/signal_rpc_dispatcher.h +++ b/repos/os/include/os/signal_rpc_dispatcher.h @@ -20,14 +20,50 @@ #include -namespace Genode { +namespace Genode { template class Signal_rpc_member; } - template - struct Signal_rpc_member : Signal_handler - { - using Signal_handler::Signal_handler; - }; -} +/** + * Signal dispatcher for handling signals by an object method + * + * This utility associates object methods with signals. It is intended to + * be used as a member variable of the class that handles incoming signals + * of a certain type. The constructor takes a pointer-to-member to the + * signal-handling method as argument. If a signal is received at the + * common signal reception code, this method will be invoked by calling + * 'Signal_dispatcher_base::dispatch'. + * + * \param T type of signal-handling class + * \param EP type of entrypoint handling signal RPC + * + * \deprecated this class template is superseded by the 'Signal_handler' + * in base/signal.h + */ +template +struct Genode::Signal_rpc_member : Genode::Signal_dispatcher_base, + Genode::Signal_context_capability +{ + EP &ep; + T &obj; + void (T::*member) (unsigned); + + /** + * Constructor + * + * \param ep entrypoint managing this signal RPC + * \param obj,member object and method to call when + * the signal occurs + */ + Signal_rpc_member(EP &ep, T &obj, void (T::*member)(unsigned)) + : Signal_context_capability(ep.manage(*this)), + ep(ep), obj(obj), member(member) { } + + ~Signal_rpc_member() { ep.dissolve(*this); } + + /** + * Interface of Signal_dispatcher_base + */ + void dispatch(unsigned num) { (obj.*member)(num); } +}; #endif /* _INCLUDE__OS__SIGNAL_RPC_DISPATCHER_H_ */