NotifierSignal Class Reference

List of all members.

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:


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.
NotifierSignaloperator= (const NotifierSignal &x)
 Assign a signal.
NotifierSignaloperator+= (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


Constructor & Destructor Documentation

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.

See also:
Router::new_notifier_signal

NotifierSignal::NotifierSignal ( const NotifierSignal x  )  [inline]

Copy construct a signal.

NotifierSignal::~NotifierSignal (  )  [inline]

Destroy a signal.


Member Function Documentation

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.

Returns:
true iff the signal is currently active.

bool NotifierSignal::active (  )  const [inline]

Return whether the signal is active.

Returns:
true iff the signal is currently active.

bool NotifierSignal::idle (  )  const [inline]

Return whether the signal is idle.

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

bool NotifierSignal::busy (  )  const [inline]

Return whether 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().

bool NotifierSignal::overderived (  )  const [inline]

Return whether 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().

bool NotifierSignal::initialized (  )  const [inline]

Return whether the signal is initialized.

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

void NotifierSignal::set_active ( bool  active  )  [inline]

Set whether the basic signal is active.

Parameters:
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.

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.

Parameters:
x the 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&)

String NotifierSignal::unparse ( Router router  )  const

Return a human-readable representation of the signal.

Parameters:
router the relevant router or null
Useful for signal debugging.

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 Function Documentation

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:

See also:
NotifierSignal::operator+=


The documentation for this class was generated from the following files:
Generated on Tue Mar 2 12:25:48 2010 for Click by  doxygen 1.5.1