eap_timer_queue_c Class Reference

class eap_timer_queue_c

User of the timer queue must be inherited from abs_eap_base_timer_c . The abs_eap_base_timer_c class is the call back interface from timer queue to the user. Note the timer queue interface is used through abs_eap_am_tools_c . Functions are abs_eap_am_tools_c::get_timer_resolution_ms() , abs_eap_am_tools_c::set_timer(), abs_eap_am_tools_c::cancel_timer(), abs_eap_am_tools_c::cancel_all_timers() and abs_eap_am_tools_c::pulse_timer() In the following figure m_timer_queue is pointer to the first timer event in the list. The timer list is horizontal list right from m_timer_queue. Each timer event in the list represents one time segment that must elapse to zero before event is active. Timer event - the square box in the figure - is type of eap_timer_queue_event_c . Each time segment includes list of the same time values, the vertical lists.

Place for new timer event is found by stepping the the horizontal timer list and adding the time values sum until the list ends or time sum is equal or greater than time of the new timer event. If time sum is equal to the time of the new timer event, the new timer event is added to the second in the vertical list. If time sum is greater than the time of the new timer event, the new timer event is added before the existing time event. In this case a new vertical list is created. If the list ends the new time event is added to the end of the timer queue.

        +---------------+  +---------------+  +---------------+
   m_timer_queue->| m_time_ms 0   |->| m_time_ms 2000|->| m_time_ms 500 | // This horizontal list is the timer queue.
                  +---------------+  +---------------+  +---------------+
                          |                  |                  |        
                          V                  V                  V        
                  +---------------+  +---------------+  +---------------+
                  | m_time_ms 0   |  | m_time_ms 0   |  | m_time_ms 0   |
                  +---------------+  +---------------+  +---------------+
                          |                  |                           
                          V                  V                           
                  +---------------+  +---------------+                   
                  | m_time_ms 0   |  | m_time_ms 0   |                   
                  +---------------+  +---------------+                   
                                             |                           
                                             V                           
                                     +---------------+                   
                                     | m_time_ms 0   |                   
                                     +---------------+                   
   // Each vertical list includes the timer events that have the same time.
       
Public Member Functions
eap_timer_queue_c ( abs_eap_am_tools_c *const , const u32_t )
~eap_timer_queue_c ()
eap_status_e cancel_all_timers ()
eap_status_e cancel_timer ( abs_eap_base_timer_c *const , const u32_t )
bool get_is_valid ()
bool get_timer_queue_is_empty ()
u32_t get_timer_resolution_ms ()
bool get_use_eap_milli_second_timer ()
u32_t pulse_timer (const u32_t , const bool)
eap_status_e re_activate_timer_queue ()
eap_status_e set_timer ( abs_eap_base_timer_c *const , const u32_t , void *const , const u32_t )
void set_timer_resolution_ms (const u32_t )
void set_use_eap_milli_second_timer (const bool)
Private Member Functions
void add_end_of_vertical_list ( eap_timer_queue_event_c *, eap_timer_queue_event_c *)
eap_status_e add_hash_of_timer_event ( eap_timer_queue_event_c *const , const abs_eap_base_timer_c *const , const u32_t )
eap_status_e add_new_pending_timer ( eap_timer_queue_event_c *)
eap_status_e add_pending_timer ()
eap_status_e add_timer ( eap_timer_queue_event_c *)
eap_status_e cancel_pending_timer ( abs_eap_base_timer_c *const , const u32_t )
void deactivate_timer_queue ()
eap_timer_queue_event_c * get_hashed_timer_event (const abs_eap_base_timer_c *const , const u32_t )
u32_t hash (const u32_t , const abs_eap_base_timer_c *const , const u32_t )
eap_status_e remove_hash_of_timer_event ( eap_timer_queue_event_c *const )
void trace_timer ()
void trace_timer_event (const eap_const_string , const eap_timer_queue_event_c *const )
Private Attributes
abs_eap_am_tools_c *const m_am_tools
bool m_is_active
bool m_is_valid
eap_timer_queue_hash_c * m_map
eap_timer_queue_event_c * m_new_event_begin
eap_timer_queue_event_c * m_new_event_end
eap_timer_queue_event_c * m_timer_queue
u32_t m_timer_resolution_ms
bool m_use_eap_millisecond_timer

Constructor & Destructor Documentation

eap_timer_queue_c(abs_eap_am_tools_c *const, const u32_t)

eap_timer_queue_c ( abs_eap_am_tools_c *const tools,
const u32_t timer_resolution_ms
)

Constructor initializes the timer queue.

Parameters

abs_eap_am_tools_c *const tools
const u32_t timer_resolution_ms is the resolution in milli seconds of this timer. The pulse() member function is assumed to be called using timer_resolution_ms interval.

~eap_timer_queue_c()

~eap_timer_queue_c ( ) [virtual]

Destructor does nothing special. Note user is assumed to call cancel_all_timers() before timer queue is deleted.

Member Functions Documentation

add_end_of_vertical_list(eap_timer_queue_event_c *, eap_timer_queue_event_c *)

void add_end_of_vertical_list ( eap_timer_queue_event_c * begin,
eap_timer_queue_event_c * event
) [private]

add_hash_of_timer_event(eap_timer_queue_event_c *const, const abs_eap_base_timer_c *const, const u32_t)

eap_status_e add_hash_of_timer_event ( eap_timer_queue_event_c *const event,
const abs_eap_base_timer_c *const initializer,
const u32_t id
) [private]

Parameters

eap_timer_queue_event_c *const event
const abs_eap_base_timer_c *const initializer
const u32_t id

add_new_pending_timer(eap_timer_queue_event_c *)

eap_status_e add_new_pending_timer ( eap_timer_queue_event_c * event ) [private]

Parameters

eap_timer_queue_event_c * event

add_pending_timer()

eap_status_e add_pending_timer ( ) [private]

New timer events are added with this function because the next pulse might be very long, and the long pulse will cause the new event expire immediately. By using this function the shortest timer events in the timer queue are handled and after that the new timer events are added to timer queue.

add_timer(eap_timer_queue_event_c *)

eap_status_e add_timer ( eap_timer_queue_event_c * event ) [private]

This function adds the timer event immediately to timer queue.

Parameters

eap_timer_queue_event_c * event

cancel_all_timers()

eap_status_e cancel_all_timers ( )

This function cancels all timer events from this timer queue. This is called before the timer queue is deleted.

cancel_pending_timer(abs_eap_base_timer_c *const, const u32_t)

eap_status_e cancel_pending_timer ( abs_eap_base_timer_c *const initializer,
const u32_t id
) [private]

This function cancels all pending timer events.

Parameters

abs_eap_base_timer_c *const initializer
const u32_t id

cancel_timer(abs_eap_base_timer_c *const, const u32_t)

eap_status_e cancel_timer ( abs_eap_base_timer_c *const initializer,
const u32_t id
)

This function cancels the timer event.

Parameters

abs_eap_base_timer_c *const initializer is the caller of this function. Call backs are directed to initializer.
const u32_t id is selected by caller. Caller could separate timer events by this value.

deactivate_timer_queue()

void deactivate_timer_queue ( ) [private]

This function deactivate this timer queue. This is called before the timer queue is deleted. Inactive timer queue does not accept new timer events.

get_hashed_timer_event(const abs_eap_base_timer_c *const, const u32_t)

eap_timer_queue_event_c * get_hashed_timer_event ( const abs_eap_base_timer_c *const initializer,
const u32_t id
) [private]

Parameters

const abs_eap_base_timer_c *const initializer
const u32_t id

get_is_valid()

bool get_is_valid ( ) const

The get_is_valid() function returns the status of the eap_core object. True indicates the object is initialized succesfully.

get_timer_queue_is_empty()

bool get_timer_queue_is_empty ( )

get_timer_resolution_ms()

u32_t get_timer_resolution_ms ( )

get_use_eap_milli_second_timer()

bool get_use_eap_milli_second_timer ( )

This function returns flag whether millisecond timer is in use (true) or not (false).

hash(const u32_t, const abs_eap_base_timer_c *const, const u32_t)

u32_t hash ( const u32_t size,
const abs_eap_base_timer_c *const initializer,
const u32_t id
) const [private]

Parameters

const u32_t size
const abs_eap_base_timer_c *const initializer
const u32_t id

pulse_timer(const u32_t, const bool)

u32_t pulse_timer ( const u32_t elapsed_time_in_ms,
const bool can_call_timer_expired_when_true
)

The pulse() member function is assumed to be called using timer_resolution_ms interval. This function decreases the remaining time of the first timer event. When remaining time reaches zero the timer queue calls the timer_expired() function. Function returns the next sleep time in milli seconds.

Parameters

const u32_t elapsed_time_in_ms
const bool can_call_timer_expired_when_true

re_activate_timer_queue()

eap_status_e re_activate_timer_queue ( )

This function re-activates timer queue. Symbian AM call this function when AM-tools object is re-used. This can be called after cancel_all_timers() function. cancel_all_timers() function de-activated timer queue.

remove_hash_of_timer_event(eap_timer_queue_event_c *const)

eap_status_e remove_hash_of_timer_event ( eap_timer_queue_event_c *const event ) [private]

Parameters

eap_timer_queue_event_c *const event

set_timer(abs_eap_base_timer_c *const, const u32_t, void *const, const u32_t)

eap_status_e set_timer ( abs_eap_base_timer_c *const initializer,
const u32_t id,
void *const data,
const u32_t time_ms
)

This function initializes a new timer event.

Parameters

abs_eap_base_timer_c *const initializer is the caller of this function. Call backs are directed to initializer.
const u32_t id is selected by caller. Caller could separate timer events by this value.
void *const data is pointer to any data. After timer is alapsed or cancelled timer queue calls timer_delete_data() function. The initializer could delete possible allocated data.
const u32_t time_ms

set_timer_resolution_ms(const u32_t)

void set_timer_resolution_ms ( const u32_t timer_resolution_ms )

Parameters

const u32_t timer_resolution_ms

set_use_eap_milli_second_timer(const bool)

void set_use_eap_milli_second_timer ( const bool use_eap_millisecond_timer )

This function activates millisecond timer with true value.

Parameters

const bool use_eap_millisecond_timer

trace_timer()

void trace_timer ( ) [private]

This function traces all initialized timer events.

trace_timer_event(const eap_const_string, const eap_timer_queue_event_c *const)

void trace_timer_event ( const eap_const_string prefix,
const eap_timer_queue_event_c *const event
) [private]

this function traces one timer event.

Parameters

const eap_const_string prefix
const eap_timer_queue_event_c *const event

Member Data Documentation

abs_eap_am_tools_c *const m_am_tools

abs_eap_am_tools_c *const m_am_tools [private]

bool m_is_active

bool m_is_active [private]

bool m_is_valid

bool m_is_valid [private]

eap_timer_queue_hash_c * m_map

eap_timer_queue_hash_c * m_map [private]

eap_timer_queue_event_c * m_new_event_begin

eap_timer_queue_event_c * m_new_event_begin [private]

These are begin and end of the list of new events that are will be added to timer queue during the next pulse_timer() function call.

eap_timer_queue_event_c * m_new_event_end

eap_timer_queue_event_c * m_new_event_end [private]

eap_timer_queue_event_c * m_timer_queue

eap_timer_queue_event_c * m_timer_queue [private]

u32_t m_timer_resolution_ms

u32_t m_timer_resolution_ms [private]

This is the resolution of this timer queue. Each pulse is assumed to be this length. This is also the minimum timer value.

bool m_use_eap_millisecond_timer

bool m_use_eap_millisecond_timer [private]