|
Click
|
An activity signal. More...
Public Types | |
| typedef bool(NotifierSignal::* | unspecified_bool_type) () const |
Public Member Functions | |
| NotifierSignal () | |
| Construct a busy signal. | |
| NotifierSignal (atomic_uint32_t *value, uint32_t mask) | |
| Construct an activity signal. | |
| NotifierSignal (const NotifierSignal &x) | |
| Copy construct a signal. | |
| ~NotifierSignal () | |
| Destroy a signal. | |
| bool | active () const |
| Test if the signal is active. | |
| bool | safe_active () const |
| Test if the signal is active. | |
| operator unspecified_bool_type () const | |
| Test if the signal is active. | |
| bool | set_active (bool active) |
| Set whether the basic signal is active. | |
| bool | idle () const |
| Test if the signal is idle. | |
| bool | busy () const |
| Test if the signal is busy. | |
| bool | overderived () const |
| Test if the signal is overderived. | |
| bool | initialized () const |
| Test if the signal is initialized. | |
| NotifierSignal & | operator= (const NotifierSignal &x) |
| Assign a signal. | |
| NotifierSignal & | operator+= (const NotifierSignal &x) |
| Make this signal derived by adding information from x. | |
| void | swap (NotifierSignal &x) |
| Exchange the values of this signal and x. | |
| String | unparse (Router *router) const |
| Return a human-readable representation of the signal. | |
Static Public Member Functions | |
| static NotifierSignal | idle_signal () |
| Return an idle signal. | |
| static NotifierSignal | busy_signal () |
| Return a busy signal. | |
| static NotifierSignal | overderived_signal () |
| Return an overderived busy signal. | |
| static NotifierSignal | uninitialized_signal () |
| Return an uninitialized signal. | |
| static void | static_initialize () |
| Initialize the NotifierSignal implementation. | |
Related Symbols | |
(Note that these are not member symbols.) | |
| bool | operator== (const NotifierSignal &a, const NotifierSignal &b) |
| Test if two NotifierSignals are equal. | |
| bool | operator!= (const NotifierSignal &a, const NotifierSignal &b) |
| Test if two NotifierSignals are unequal. | |
| NotifierSignal | operator+ (NotifierSignal a, const NotifierSignal &b) |
| Return a derived signal. | |
An activity signal.
Activity signals in Click let one element determine whether another element is active. For example, consider an element X pulling from a Queue. If the Queue is empty, there's no point in X trying to pull from it. Thus, the Queue has an activity signal that's active when it contains packets and inactive when it's empty. X can check the activity signal before pulling, and do something else if it's inactive. Combined with the sleep/wakeup functionality of ActiveNotifier, this can greatly reduce CPU load due to polling.
A "basic activity signal" is essentially a bit that's either on or off. When it's on, the signal is active. NotifierSignal can represent derived activity signals as well. A derived signal combines information about N basic signals using the following invariant: If any of the basic signals is active, then the derived signal is also active. There are no other guarantees; in particular, the derived signal might be active even if none of the basic signals are active.
Click elements construct NotifierSignal objects in four ways:
|
inline |
Construct a busy signal.
The returned signal is always active.
|
inline |
Construct an activity signal.
Elements should not use this constructor directly.
|
inline |
Copy construct a signal.
|
inline |
Destroy a signal.
|
inlinestatic |
Return an idle signal.
The returned signal is never active.
|
inlinestatic |
Return a busy signal.
The returned signal is always active.
|
inlinestatic |
Return an overderived busy signal.
Overderived signals replace derived signals that are too complex to represent. An overderived signal, like a busy signal, is always active.
|
inlinestatic |
Return an uninitialized signal.
Uninitialized signals may be used occasionally as placeholders for true signals to be added later. Uninitialized signals are never active.
|
inline |
Test if the signal is active.
|
inline |
Test if the signal is active.
|
inline |
Test if the signal is active.
|
inline |
Set whether the basic signal is active.
| active | true iff the basic signal is active |
Use this function to set whether a basic signal is active.
It is illegal to call set_active() on derived, idle, busy, or overderived signals. Some of these actions may cause an assertion failure.
|
inline |
Test if the signal is idle.
|
inline |
Test if the signal is busy.
|
inline |
Test if the signal is overderived.
|
inline |
Test if the signal is initialized.
|
inline |
Assign a signal.
| NotifierSignal & NotifierSignal::operator+= | ( | const NotifierSignal & | x | ) |
Make this signal derived by adding information from x.
| x | the signal to add |
Creates a derived signal that combines information from this signal and x. Equivalent to "*this = (*this + @a x)".
|
inline |
Exchange the values of this signal and x.
Return a human-readable representation of the signal.
| router | the relevant router or null |
Useful for signal debugging.
|
static |
Initialize the NotifierSignal implementation.
This function must be called before NotifierSignal functionality is used. It is safe to call it multiple times.
|
related |
Test if two NotifierSignals are equal.
Returns true iff the two NotifierSignals are the same – i.e., they combine information about exactly the same sets of basic signals.
All idle() signals compare equal. busy_signal() and overderived_signal() do not compare equal, however.
|
related |
Test if two NotifierSignals are unequal.
Returns true iff !(a == b).
|
related |
Return a derived signal.
Returns a derived signal that combines information from its arguments. The result will be active whenever a and/or b is active. If the combination of a and b is too complex to represent, returns an overderived signal; this trivially follows the invariant since it is always active.
Signal derivation is commutative and associative. The following special combinations are worth remembering: