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:
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. | |
| operator unspecified_bool_type () const | |
| Return whether the signal is active. | |
| bool | active () const |
| Return whether the signal is active. | |
| bool | idle () const |
| Return whether the signal is idle. | |
| bool | busy () const |
| Return whether the signal is busy. | |
| bool | overderived () const |
| Return whether the signal is overderived. | |
| bool | initialized () const |
| Return whether the signal is initialized. | |
| void | set_active (bool active) |
| Set whether the basic signal is active. | |
| NotifierSignal & | operator= (const NotifierSignal &x) |
| Assign a signal. | |
| NotifierSignal & | operator+= (const NotifierSignal &x) |
| Make this signal derived by adding information from 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 Functions | |
| (Note that these are not member functions.) | |
| bool | operator== (const NotifierSignal &a, const NotifierSignal &b) |
| Compare two NotifierSignals for equality. | |
| bool | operator!= (const NotifierSignal &a, const NotifierSignal &b) |
| Compare two NotifierSignals for inequality. | |
| NotifierSignal | operator+ (NotifierSignal a, const NotifierSignal &b) |
| Return a derived signal. | |
Classes | |
| struct | vmpair |
| NotifierSignal::NotifierSignal | ( | ) | [inline] |
Construct a busy signal.
The returned signal is always active.
| NotifierSignal::NotifierSignal | ( | atomic_uint32_t * | value, | |
| uint32_t | mask | |||
| ) | [inline] |
Construct an activity signal.
Elements should not use this constructor directly.
| NotifierSignal::NotifierSignal | ( | const NotifierSignal & | x | ) | [inline] |
Copy construct a signal.
| NotifierSignal::~NotifierSignal | ( | ) | [inline] |
Destroy a signal.
| NotifierSignal NotifierSignal::idle_signal | ( | ) | [inline, static] |
Return an idle signal.
The returned signal is never active.
| NotifierSignal NotifierSignal::busy_signal | ( | ) | [inline, static] |
Return a busy signal.
The returned signal is always active.
| NotifierSignal NotifierSignal::overderived_signal | ( | ) | [inline, static] |
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.
| NotifierSignal NotifierSignal::uninitialized_signal | ( | ) | [inline, static] |
Return an uninitialized signal.
Uninitialized signals may be used occasionally as placeholders for true signals to be added later. Uninitialized signals are never active.
| NotifierSignal::operator unspecified_bool_type | ( | ) | const [inline] |
Return whether the signal is active.
| bool NotifierSignal::active | ( | ) | const [inline] |
Return whether the signal is active.
| bool NotifierSignal::idle | ( | ) | const [inline] |
Return whether the signal is idle.
| bool NotifierSignal::busy | ( | ) | const [inline] |
Return whether the signal is busy.
| bool NotifierSignal::overderived | ( | ) | const [inline] |
Return whether the signal is overderived.
| bool NotifierSignal::initialized | ( | ) | const [inline] |
Return whether the signal is initialized.
| void NotifierSignal::set_active | ( | bool | active | ) | [inline] |
Set whether the basic signal is active.
| active | true iff the 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.
| NotifierSignal & NotifierSignal::operator= | ( | const NotifierSignal & | x | ) | [inline] |
Assign a signal.
| NotifierSignal & NotifierSignal::operator+= | ( | const NotifierSignal & | x | ) |
Make this signal derived by adding information from x.
| x | the signal to add |
Return a human-readable representation of the signal.
| router | the relevant router or null |
| void NotifierSignal::static_initialize | ( | ) | [static] |
Initialize the NotifierSignal implementation.
This function must be called before NotifierSignal functionality is used. It is safe to call it multiple times.
| bool operator== | ( | const NotifierSignal & | a, | |
| const NotifierSignal & | b | |||
| ) | [friend] |
Compare two NotifierSignals for equality.
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.
| bool operator!= | ( | const NotifierSignal & | a, | |
| const NotifierSignal & | b | |||
| ) | [friend] |
Compare two NotifierSignals for inequality.
Returns true iff !(a == b).
| NotifierSignal operator+ | ( | NotifierSignal | a, | |
| const NotifierSignal & | b | |||
| ) | [friend] |
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:
1.5.1