Public Types | Public Member Functions | Protected Attributes | Private Member Functions

ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK > Class Template Reference

Iterates over an ACE_Timer_Wheel. More...

#include <Timer_Wheel_T.h>

Inheritance diagram for ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >:
Inheritance graph
[legend]
Collaboration diagram for ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef ACE_Timer_Wheel_T
< TYPE, FUNCTOR, ACE_LOCK > 
Wheel
typedef ACE_Timer_Node_T< TYPE > Node

Public Member Functions

 ACE_Timer_Wheel_Iterator_T (Wheel &)
 Constructor.
 ~ACE_Timer_Wheel_Iterator_T (void)
 Destructor.
virtual void first (void)
 Positions the iterator at the earliest node in the Timer Queue.
virtual void next (void)
 Positions the iterator at the next node in the Timer Queue.
virtual bool isdone (void) const
 Returns true when there are no more nodes in the sequence.
virtual ACE_Timer_Node_T< TYPE > * item (void)
 Returns the node at the current position in the sequence.

Protected Attributes

Wheeltimer_wheel_
 Pointer to the ACE_Timer_List that we are iterating over.
u_int spoke_
 Current position in the timing wheel.
ACE_Timer_Node_T< TYPE > * current_node_
 Pointer to the position in the the <pos_>th list.

Private Member Functions

void goto_next (u_int start_spoke)
 Helper class for common functionality of next() and first().

Detailed Description

template<class TYPE, class FUNCTOR, class ACE_LOCK>
class ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >

Iterates over an ACE_Timer_Wheel.

This is a generic iterator that can be used to visit every node of a timer queue. Be aware that it doesn't traverse in the order of timeout values.

Definition at line 39 of file Timer_Wheel_T.h.


Member Typedef Documentation

template<class TYPE , class FUNCTOR , class ACE_LOCK >
typedef ACE_Timer_Node_T<TYPE> ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >::Node

Definition at line 44 of file Timer_Wheel_T.h.

template<class TYPE , class FUNCTOR , class ACE_LOCK >
typedef ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK> ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >::Wheel

Definition at line 43 of file Timer_Wheel_T.h.


Constructor & Destructor Documentation

template<class TYPE , class FUNCTOR , class ACE_LOCK >
ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >::ACE_Timer_Wheel_Iterator_T ( Wheel wheel  ) 

Constructor.

Just initializes the iterator with a ACE_Timer_Wheel_T and then calls first() to initialize the rest of itself.

Parameters:
wheel A reference for a timer queue to iterate over

Definition at line 871 of file Timer_Wheel_T.cpp.

: timer_wheel_ (wheel)
{
  this->first();
}

template<class TYPE , class FUNCTOR , class ACE_LOCK >
ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >::~ACE_Timer_Wheel_Iterator_T ( void   ) 

Destructor.

Destructor, at this level does nothing.

Definition at line 884 of file Timer_Wheel_T.cpp.

{
}


Member Function Documentation

template<class TYPE , class FUNCTOR , class ACE_LOCK >
void ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >::first ( void   )  [virtual]

Positions the iterator at the earliest node in the Timer Queue.

Positions the iterator at the first position in the timing wheel that contains something. spoke_ will be set to the spoke position of this entry and current_node_ will point to the first entry in that spoke.

If the wheel is empty, spoke_ will be equal timer_wheel_.spoke_count_ and current_node_ would be 0.

Implements ACE_Timer_Queue_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >.

Definition at line 898 of file Timer_Wheel_T.cpp.

{
  this->goto_next(0);
}

template<class TYPE , class FUNCTOR , class ACE_LOCK >
void ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >::goto_next ( u_int  start_spoke  )  [private]

Helper class for common functionality of next() and first().

Definition at line 923 of file Timer_Wheel_T.cpp.

{
  // Find the first non-empty entry.
  u_int sc = this->timer_wheel_.spoke_count_;
  for (u_int i = start_spoke; i < sc; ++i)
  {
    ACE_Timer_Node_T<TYPE>* root = this->timer_wheel_.spokes_[i];
    ACE_Timer_Node_T<TYPE>* n = root->get_next ();
    if (n != root)
      {
        this->spoke_ = i;
        this->current_node_ = n;
        return;
      }
  }
  // empty
  this->spoke_ = sc;
  this->current_node_ = 0;
}

template<class TYPE , class FUNCTOR , class ACE_LOCK >
bool ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >::isdone ( void   )  const [virtual]

Returns true when there are no more nodes in the sequence.

Returns:
True when we there aren't any more items (when current_node_ == 0)

Implements ACE_Timer_Queue_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >.

Definition at line 947 of file Timer_Wheel_T.cpp.

{
  return this->current_node_ == 0;
}

template<class TYPE , class FUNCTOR , class ACE_LOCK >
ACE_Timer_Node_T< TYPE > * ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >::item ( void   )  [virtual]

Returns the node at the current position in the sequence.

Returns:
The node at the current spokeition in the sequence or 0 if the wheel is empty

Implements ACE_Timer_Queue_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >.

Definition at line 957 of file Timer_Wheel_T.cpp.

{
  return this->current_node_;
}

template<class TYPE , class FUNCTOR , class ACE_LOCK >
void ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >::next ( void   )  [virtual]

Positions the iterator at the next node in the Timer Queue.

Positions the iterator at the next node.

Implements ACE_Timer_Queue_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >.

Definition at line 908 of file Timer_Wheel_T.cpp.

{
  if (this->isdone())
    return;

  ACE_Timer_Node_T<TYPE>* n = this->current_node_->get_next ();
  ACE_Timer_Node_T<TYPE>* root = this->timer_wheel_.spokes_[this->spoke_];
  if (n == root)
    this->goto_next (this->spoke_ + 1);
  else
    this->current_node_ = n;
}


Member Data Documentation

template<class TYPE , class FUNCTOR , class ACE_LOCK >
ACE_Timer_Node_T<TYPE>* ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >::current_node_ [protected]

Pointer to the position in the the <pos_>th list.

Definition at line 72 of file Timer_Wheel_T.h.

template<class TYPE , class FUNCTOR , class ACE_LOCK >
u_int ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >::spoke_ [protected]

Current position in the timing wheel.

Definition at line 69 of file Timer_Wheel_T.h.

template<class TYPE , class FUNCTOR , class ACE_LOCK >
Wheel& ACE_Timer_Wheel_Iterator_T< TYPE, FUNCTOR, ACE_LOCK >::timer_wheel_ [protected]

Pointer to the ACE_Timer_List that we are iterating over.

Definition at line 66 of file Timer_Wheel_T.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines