Public Member Functions

gnash::Timer Class Reference

An interval timer. More...

#include <Timers.h>

Collaboration diagram for gnash::Timer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~Timer ()
 Timer (as_function &method, unsigned long ms, as_object *this_ptr, const fn_call::Args &args, bool runOnce=false)
 Construct a Timer, enabling it.
 Timer (as_object *obj, string_table::key methodName, unsigned long ms, const fn_call::Args &args, bool runOnce=false)
 Construct the Timer to call a late-evaluated object method, enabling it.
void clearInterval ()
 Clear the timer, ready for reuse.
bool expired (unsigned long now, unsigned long &elapsed)
 Get expiration state.
bool cleared () const
 Return true if interval has been cleared.
void executeAndReset ()
 Execute associated function and reset state.
void markReachableResources () const
 Mark all reachable resources (for GC).

Detailed Description

An interval timer.

This is constructed when _global.setInterval() is called. Instances of this class will be stored in the movie_root singleton.

A timer has a function to call, a context in which to call it, a list of arguments and an interval specifying how often the function must be called.

It is *not* a "smart" timer, which is it will *not* automatically execute at given intervals. Rather, it will be movie_root responsibility to execute the timer-associated function at regular intervals. As a facility, the Timer class provides an execution operator, proxying the execution to the associated function with properly set-up context.


Constructor & Destructor Documentation

gnash::Timer::~Timer (  ) 
gnash::Timer::Timer ( as_function method,
unsigned long  ms,
as_object this_ptr,
const fn_call::Args args,
bool  runOnce = false 
)

Construct a Timer, enabling it.

Parameters:
method The function to call from execution operator. Will be stored in an intrusive_ptr.
ms The number of milliseconds between expires.
this_ptr The object to be used as 'this' pointer when calling the associated function. Will be stored in an intrusive_ptr. It is allowed to be NULL as long as fn_call is allowed a NULL as 'this_ptr' (we might want to change this).
args The list of arguments to pass to the function being invoked.
runOnce If true the interval will run only once. False if omitted.
gnash::Timer::Timer ( as_object obj,
string_table::key  methodName,
unsigned long  ms,
const fn_call::Args args,
bool  runOnce = false 
)

Construct the Timer to call a late-evaluated object method, enabling it.

Parameters:
this_ptr The object to be used as 'this' pointer when calling the associated function. Will be stored in an intrusive_ptr. It is allowed to be NULL as long as fn_call is allowed a NULL as 'this_ptr' (we might want to change this).
methodName The method name to call from execution operator.
ms The number of milliseconds between expires.
args The list of arguments to pass to the function being invoked.
runOnce If true the interval will run only once. False if omitted.

Member Function Documentation

bool gnash::Timer::cleared (  )  const [inline]

Return true if interval has been cleared.

Note that the timer is constructed as cleared and you need to call setInterval() to make it not-cleared.

Referenced by executeAndReset(), expired(), and gnash::movie_root::markReachableResources().

void gnash::Timer::clearInterval (  ) 

Clear the timer, ready for reuse.

When a Timer is cleared, the expired() function will always return false.

Use setInterval() to reset it.

Referenced by executeAndReset().

void gnash::Timer::executeAndReset (  ) 

Execute associated function and reset state.

After execution either the timer is cleared (if runOnce) or start time is incremented by the interval.

NOTE: if the timer is cleared this call results in a no-op.

References cleared(), and clearInterval().

bool gnash::Timer::expired ( unsigned long  now,
unsigned long &  elapsed 
)

Get expiration state.

Current time, in milliseconds.

Parameters:
elapsed Output parameter, will be set to the amount of milliseconds elapsed since actual expiration, if expired.
Returns:
true if the timer expired, false otherwise.

References cleared().

Referenced by gnash::movie_root::markReachableResources().

void gnash::Timer::markReachableResources (  )  const

Mark all reachable resources (for GC).

Resources reachable from Timer are:

  • Arguments list (_args)
  • Associated function (_function)
  • Target object (_object)

References gnash::GcResource::setReachable(), and gnash::FunctionArgs< T >::setReachable().


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