|
Click
|
A basic activity signal and notification provider. More...
Public Types | |
| enum | SearchOp { SEARCH_STOP = 0 , SEARCH_CONTINUE , SEARCH_CONTINUE_WAKE } |
| typedef void(* | callback_type) (void *, Notifier *) |
Public Member Functions | |
| Notifier (SearchOp op=SEARCH_STOP) | |
| Constructs a Notifier. | |
| Notifier (const NotifierSignal &signal, SearchOp op=SEARCH_STOP) | |
| Constructs a Notifier associated with a given signal. | |
| virtual | ~Notifier () |
| Destruct a Notifier. | |
| bool | initialized () const |
| Return whether the Notifier is initialized. | |
| int | initialize (const char *name, Router *router) |
| Initialize the associated NotifierSignal, if necessary. | |
| const NotifierSignal & | signal () const |
| Return this Notifier's associated NotifierSignal. | |
| SearchOp | search_op () const |
| Return this Notifier's search operation. | |
| bool | active () const |
| Returns whether the associated signal is active. | |
| bool | safe_active () const |
| Returns whether the associated signal is active. | |
| bool | set_active (bool active) |
| Set the associated signal's activity. | |
| void | wake () |
| Set the associated signal to active. | |
| void | sleep () |
| Set the associated signal to inactive. | |
| virtual int | add_activate_callback (callback_type f, void *user_data) |
| Register an activate callback with this Notifier. | |
| virtual void | remove_activate_callback (callback_type f, void *user_data) |
| Unregister an activate callback with this Notifier. | |
| int | add_listener (Task *task) |
| Register a listener with this Notifier. | |
| void | remove_listener (Task *task) |
| Unregister a listener with this Notifier. | |
| int | add_dependent_signal (NotifierSignal *signal) |
| Register a dependent signal with this Notifier. | |
| void | remove_dependent_signal (NotifierSignal *signal) |
| Unregister a dependent signal with this Notifier. | |
Static Public Member Functions | |
| static NotifierSignal | upstream_empty_signal (Element *e, int port) |
| Calculate and return the NotifierSignal derived from all empty notifiers upstream of element e's input port. | |
| static NotifierSignal | upstream_empty_signal (Element *e, int port, Task *task) |
| Calculate and return the NotifierSignal derived from all empty notifiers upstream of element e's input port. | |
| static NotifierSignal | upstream_empty_signal (Element *e, int port, Notifier *dependent_notifier) |
| Calculate and return the NotifierSignal derived from all empty notifiers upstream of element e's input port. | |
| static NotifierSignal | upstream_signal (Element *e, int port, Task *task, const char *signal) |
| Calculate and return the NotifierSignal derived from all empty notifiers upstream of element e's input port. | |
| static NotifierSignal | upstream_empty_signal (Element *e, int port, callback_type f, void *user_data) |
| Calculate and return the NotifierSignal derived from all empty notifiers upstream of element e's input port. | |
| static NotifierSignal | upstream_signal (Element *e, int port, callback_type f, void *user_data, const char *signal) |
| Calculate and return the NotifierSignal derived from all empty notifiers upstream of element e's input port. | |
| static NotifierSignal | downstream_full_signal (Element *e, int port) |
| Calculate and return the NotifierSignal derived from all full notifiers downstream of element e's output port. | |
| static NotifierSignal | downstream_full_signal (Element *e, int port, Task *task) |
| Calculate and return the NotifierSignal derived from all full notifiers downstream of element e's output port. | |
| static NotifierSignal | downstream_full_signal (Element *e, int port, Notifier *dependent_notifier) |
| Calculate and return the NotifierSignal derived from all full notifiers downstream of element e's output port. | |
| static NotifierSignal | downstream_full_signal (Element *e, int port, callback_type f, void *user_data) |
| Calculate and return the NotifierSignal derived from all full notifiers downstream of element e's output port. | |
| static NotifierSignal | upstream_empty_signal (Element *e, int port, int) |
| static NotifierSignal | upstream_empty_signal (Element *e, int port, int, Notifier *) |
| static NotifierSignal | downstream_full_signal (Element *e, int port, int) |
| static NotifierSignal | downstream_full_signal (Element *e, int port, int, Notifier *) |
Static Public Attributes | |
| static const char | EMPTY_NOTIFIER [] = "empty" |
| static const char | FULL_NOTIFIER [] = "full" |
A basic activity signal and notification provider.
The Notifier class represents a basic activity signal associated with an element. Elements that contain a Notifier object will override Element::cast() or Element::port_cast() to return that Notifier when given the proper name. This lets other parts of the configuration find the Notifiers. See upstream_empty_signal() and downstream_full_signal().
The ActiveNotifier class, which derives from Notifier, can wake up clients when its activity signal becomes active.
|
inline |
Constructs a Notifier.
| op | controls notifier path search |
This function constructs a Notifier object. The Notifier's associated NotifierSignal is initially idle; it becomes associated with a signal after initialize() is called.
The op argument controls path search. The rest of this entry describes it further.
Elements interested in notification generally search for Notifier objects along all possible packet paths upstream (or downstream) of one of their ports. When a Notifier is found along a path, further searching along that path is cut off, so only the closest Notifiers are found. Sometimes, however, it makes more sense to continue searching for more Notifiers. The correct behavior is Notifier-specific, and is controlled by this method. When the search encounters a Notifier, it consults the Notifier's op variable supplied to the constructor. It should equal one of three SearchOp constants, which correspond to the following behavior:
|
inline |
Constructs a Notifier associated with a given signal.
| signal | the associated NotifierSignal |
| op | controls notifier path search |
This function constructs a Notifier object associated with a specific NotifierSignal, such as NotifierSignal::idle_signal(). Calling initialize() on this Notifier will not change the associated NotifierSignal. The op argument is as in Notifier::Notifier(SearchOp), above.
|
virtual |
Destruct a Notifier.
|
inline |
Return whether the Notifier is initialized.
| int Notifier::initialize | ( | const char * | name, |
| Router * | r | ||
| ) |
Initialize the associated NotifierSignal, if necessary.
| name | signal name |
| r | associated router |
Initialize the Notifier's associated NotifierSignal by calling r's Router::new_notifier_signal() method, obtaining a new basic activity signal. Does nothing if the signal is already initialized.
|
inline |
Return this Notifier's associated NotifierSignal.
Every Notifier object corresponds to one NotifierSignal; this method returns it. The signal is idle() before initialize() is called.
|
inline |
Return this Notifier's search operation.
|
inline |
|
inline |
Returns whether the associated signal is active.
Same as signal().safe_active().
|
inline |
Set the associated signal's activity.
| active | true iff the signal should be active |
|
inline |
Set the associated signal to active.
|
inline |
Set the associated signal to inactive.
|
virtual |
Register an activate callback with this Notifier.
| f | callback function |
| user_data | callback data for f |
When this Notifier's associated signal is activated, this Notifier should call f(user_data, this). Not all types of Notifier provide this functionality. The default implementation does nothing.
If f is null, then user_data is a Task pointer passed to add_listener.
Reimplemented in ActiveNotifier.
|
virtual |
Unregister an activate callback with this Notifier.
| f | callback function |
| user_data | callback data for f |
Undoes the effect of all prior add_activate_callback(f, user_data) calls. Does nothing if (f,user_data) was never added. The default implementation does nothing.
If f is null, then user_data is a Task pointer passed to remove_listener.
Reimplemented in ActiveNotifier.
|
inline |
|
inline |
Unregister a listener with this Notifier.
| task | listener Task |
Undoes the effect of all prior add_listener(task) calls. Does nothing if task was never added. The default implementation does nothing.
|
inline |
|
inline |
Unregister a dependent signal with this Notifier.
| signal | dependent signal |
Undoes the effect of all prior add_dependent_signal(signal) calls. Does nothing if signal was never added. The default implementation does nothing.
|
inlinestatic |
Calculate and return the NotifierSignal derived from all empty notifiers upstream of element e's input port.
| e | an element |
| port | the input port of e at which to start the upstream search |
Searches the configuration upstream of element e's input port for empty notifiers. These notifiers are associated with packet storage, and should be true when packets are available (or likely to be available quite soon), and false when they are not. All notifiers found are combined into a single derived signal. Thus, if any of the base notifiers are active, indicating that at least one packet is available upstream, the derived signal will also be active. Element e's code generally uses the resulting signal to decide whether or not to reschedule itself.
The returned signal is generally conservative, meaning that the signal is true whenever a packet exists upstream, but the elements that provide notification are responsible for ensuring this.
Overloaded versions of this function can also register a task (as in add_listener()), a signal (as in add_dependent_notifier()), or a callback function (as in add_active_callback()) for each located notifier. When packets become available, the task will be scheduled, the signal will be activated, or the callback will be called.
Elements that have an empty notifier must override the Element::cast() method. When passed the name Notifier::EMPTY_NOTIFIER, this method should return a pointer to the corresponding Notifier object.
|
inlinestatic |
Calculate and return the NotifierSignal derived from all empty notifiers upstream of element e's input port.
| e | an element |
| port | the input port of e at which to start the upstream search |
| task | task to schedule when packets become available |
|
inlinestatic |
Calculate and return the NotifierSignal derived from all empty notifiers upstream of element e's input port.
| e | an element |
| port | the input port of e at which to start the upstream search |
| notifier | notifier to activate when packets become available |
|
inlinestatic |
Calculate and return the NotifierSignal derived from all empty notifiers upstream of element e's input port.
| e | an element |
| port | the input port of e at which to start the upstream search |
| task | task to schedule when packets become available |
| signal | signal to upstream |
|
inlinestatic |
Calculate and return the NotifierSignal derived from all empty notifiers upstream of element e's input port.
| e | an element |
| port | the input port of e at which to start the upstream search |
| f | callback function |
| user_data | user data for callback function |
|
static |
Calculate and return the NotifierSignal derived from all empty notifiers upstream of element e's input port.
| e | an element |
| port | the input port of e at which to start the upstream search |
| f | callback function |
| user_data | user data for callback function |
| signal | signal to upstream |
|
inlinestatic |
Calculate and return the NotifierSignal derived from all full notifiers downstream of element e's output port.
| e | an element |
| port | the output port of e at which to start the downstream search |
Searches the configuration downstream of element e's output port for full notifiers. These notifiers are associated with packet storage, and should be true when there is space for at least one packet, and false when there is not. All notifiers found are combined into a single derived signal. Thus, if any of the base notifiers are active, indicating that at least one path has available space, the derived signal will also be active. Element e's code generally uses the resulting signal to decide whether or not to reschedule itself.
Overloaded versions of this function can also register a task (as in add_listener()), a signal (as in add_dependent_notifier()), or a callback function (as in add_active_callback()) for each located notifier. When space becomes available, the task will be scheduled, the signal will be activated, or the callback will be called.
In current Click, the returned signal is conservative: if it's inactive, then there is no space for packets downstream.
Elements that have a full notifier must override the Element::cast() method. When passed the name Notifier::FULL_NOTIFIER, this method should return a pointer to the corresponding Notifier object.
|
inlinestatic |
Calculate and return the NotifierSignal derived from all full notifiers downstream of element e's output port.
| e | an element |
| port | the output port of e at which to start the downstream search |
| task | task to schedule when packets become available |
|
inlinestatic |
Calculate and return the NotifierSignal derived from all full notifiers downstream of element e's output port.
| e | an element |
| port | the output port of e at which to start the downstream search |
| notifier | notifier to activate when packets become available |
|
static |
Calculate and return the NotifierSignal derived from all full notifiers downstream of element e's output port.
| e | an element |
| port | the output port of e at which to start the downstream search |
| f | callback function |
| user_data | user data for callback function |