Click
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Related Symbols | List of all members
NotifierSignal Class Reference

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.
 

Detailed Description

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:

Constructor & Destructor Documentation

◆ NotifierSignal() [1/3]

NotifierSignal::NotifierSignal ( )
inline

Construct a busy signal.

The returned signal is always active.

◆ NotifierSignal() [2/3]

NotifierSignal::NotifierSignal ( atomic_uint32_t *  value,
uint32_t  mask 
)
inline

Construct an activity signal.

Elements should not use this constructor directly.

See also
Router::new_notifier_signal

◆ NotifierSignal() [3/3]

NotifierSignal::NotifierSignal ( const NotifierSignal &  x)
inline

Copy construct a signal.

◆ ~NotifierSignal()

NotifierSignal::~NotifierSignal ( )
inline

Destroy a signal.

Member Function Documentation

◆ idle_signal()

NotifierSignal NotifierSignal::idle_signal ( )
inlinestatic

Return an idle signal.

The returned signal is never active.

◆ busy_signal()

NotifierSignal NotifierSignal::busy_signal ( )
inlinestatic

Return a busy signal.

The returned signal is always active.

◆ overderived_signal()

NotifierSignal NotifierSignal::overderived_signal ( )
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.

◆ uninitialized_signal()

NotifierSignal NotifierSignal::uninitialized_signal ( )
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.

◆ active()

bool NotifierSignal::active ( ) const
inline

Test if the signal is active.

◆ safe_active()

bool NotifierSignal::safe_active ( ) const
inline

Test if the signal is active.

◆ operator unspecified_bool_type()

NotifierSignal::operator unspecified_bool_type ( ) const
inline

Test if the signal is active.

◆ set_active()

bool NotifierSignal::set_active ( bool  active)
inline

Set whether the basic signal is active.

Parameters
activetrue iff the basic signal is active
Returns
previous active state

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.

◆ idle()

bool NotifierSignal::idle ( ) const
inline

Test if the signal is idle.

Returns
true iff the signal is idle, i.e. it will never be active.

◆ busy()

bool NotifierSignal::busy ( ) const
inline

Test if the signal is busy.

Returns
true iff the signal is busy, i.e. it will always be active.
Note
An overderived_signal() is busy(), but a busy_signal() is not overderived().

◆ overderived()

bool NotifierSignal::overderived ( ) const
inline

Test if the signal is overderived.

Returns
true iff the signal equals overderived_signal().
Note
An overderived_signal() is busy(), but a busy_signal() is not overderived().

◆ initialized()

bool NotifierSignal::initialized ( ) const
inline

Test if the signal is initialized.

Returns
true iff the signal doesn't equal uninitialized_signal().

◆ operator=()

NotifierSignal & NotifierSignal::operator= ( const NotifierSignal &  x)
inline

Assign a signal.

◆ operator+=()

NotifierSignal & NotifierSignal::operator+= ( const NotifierSignal &  x)

Make this signal derived by adding information from x.

Parameters
xthe signal to add

Creates a derived signal that combines information from this signal and x. Equivalent to "*this = (*this + @a x)".

See also
operator+(NotifierSignal, const NotifierSignal&)

◆ swap()

void NotifierSignal::swap ( NotifierSignal &  x)
inline

Exchange the values of this signal and x.

◆ unparse()

String NotifierSignal::unparse ( Router *  router) const

Return a human-readable representation of the signal.

Parameters
routerthe relevant router or null

Useful for signal debugging.

◆ static_initialize()

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.

Note
Elements don't need to worry about static_initialize(); Click drivers have already called it for you.

Friends And Related Symbol Documentation

◆ operator==()

bool operator== ( const NotifierSignal &  a,
const NotifierSignal &  b 
)
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.

◆ operator!=()

bool operator!= ( const NotifierSignal &  a,
const NotifierSignal &  b 
)
related

Test if two NotifierSignals are unequal.

Returns true iff !(a == b).

◆ operator+()

NotifierSignal operator+ ( NotifierSignal  a,
const NotifierSignal &  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:

See also
NotifierSignal::operator+=

The documentation for this class was generated from the following files: