Main Page   Class Hierarchy   Compound List   File List   Header Files   Compound Members   File Members  

itimer.h

This is the verbatim text of the itimer.h include file.
/* Sun-$Revision: 23.5 $ */

/* Copyright 1992-9 Sun Microsystems, Inc. and Stanford University.
   See the LICENSE file for license information. */

# pragma interface

// IntervalTimers manage all periodical "tasks".  (The VM can register
// functions which get called at specified intervals.)

class TimerEntry; // defined in itimer_<os>.c


// the portable one, for a platform must
//  refine this and typedef IntervalTimer to it
class IntervalTimer {
  friend class TimerEntry;
  
 private:
  static IntervalTimer* _Real_timer;
  static IntervalTimer*  _CPU_timer;
  static const int number_of_entries = 5;
  int32 registered;
  TimerEntry* _t;
  
 public:    
  static bool dont_use_real_timer;   // disable real-timer
  static bool dont_use_any_timer;    // disable all timers
  
  
  // The Interface:
  
 public:
  // defined per-platform
  static void init();
  static void exit();
  
  // There are two timers, and you enroll and withdraw individual activities.
  static IntervalTimer*  Real_timer() { return _Real_timer; }
  static IntervalTimer*   CPU_timer() { return  _CPU_timer; }
  
  // Global timer operations
  static void    start_all();
  static void   enable_all();
  static void  disable_all(bool skipAsserts);
  static void do_tasks_all();


  // Self-level enroll:
  static smi  setCPUTimer_prim(smi ms);  // NB: caller must guarantee ms >= 0.
  static smi setRealTimer_prim(smi ms);  // NB: caller must guarantee ms >= 0.
  
  // VM-level matriculation
  void enroll(float frequency, doFn sync_fn, doFn async_fn = NULL);    
  void withdraw(doFn proc);
  
  // Other per-timer operations:
  
  int32 ticks_per_second(); // for spy, profilers, etc.
  
  void  enable();
  void  disable(bool noAsserts);
  
  
  
 private:
  IntervalTimer();
  ~IntervalTimer();
  void common_initialization();
  void common_finalization();
  
  void  start()         { enable(); };

 public: // (some plats)
  void do_tasks();

 private:
  TimerEntry* entries() { return _t; }
  TimerEntry* entry_at(int i); // must be defined per-platform
  TimerEntry* alloc_entry();
  
  void withdraw_entry(TimerEntry*);
  void move_entry(TimerEntry* from, TimerEntry* to);
  
  smi setTimer_prim(smi ms, doFn tick_fn);
  
# include "_itimer_pd.h.incl"

};


class AbstractTimerEntry {

 protected:

  // async is called first, then sync
  doFn async_fn; // called from interrupt routine
  doFn sync_fn;  // called synchronously
  
 public:
 
   void initialize(doFn sp, doFn ap) { sync_fn = sp;  async_fn = ap; }
 
   bool includes_fn(doFn sync_or_async_fn) {
    return     sync_fn == sync_or_async_fn
           || async_fn == sync_or_async_fn;
  }
};


Generated at Tue Jun 27 12:07:06 2000 for SelfVM by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999