1 // event.hxx -- Flight Gear periodic event scheduler
3 // Written by Curtis Olson, started December 1997.
5 // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 // (Log is kept at end of this file)
30 # error This library requires C++
34 #include <deque.h> // STL double ended queue
35 #include <list.h> // STL list
37 #include "fg_time.hxx"
40 #define FG_EVENT_SUSP 0
41 #define FG_EVENT_READY 1
42 #define FG_EVENT_QUEUED 2
46 char description[256];
48 void (*event)( void ); // pointer to function
49 int status; // status flag
51 long interval; // interval in ms between each iteration of this event
53 fg_timestamp last_run;
55 fg_timestamp next_run;
57 long cum_time; // cumulative processor time of this event
58 long min_time; // time of quickest execution
59 long max_time; // time of slowest execution
60 long count; // number of times executed
67 deque < fgEVENT > event_table;
70 list < fgEVENT * > run_queue;
77 // Initialize the scheduling subsystem
80 // Register an event with the scheduler
81 void Register(char *desc, void (*event)( void ), int status,
84 // Update the scheduling parameters for an event
87 // Delete a scheduled event
90 // Temporarily suspend scheduling of an event
93 // Resume scheduling and event
96 // Dump scheduling stats
97 void PrintStats( void );
99 // Add pending jobs to the run queue and run the job at the front
101 void Process( void );
104 ~fgEVENT_MGR ( void );
108 // Wrapper to dump scheduling stats
109 void fgEventPrintStats( void );
111 extern fgEVENT_MGR global_events;
118 // Revision 1.2 1998/05/22 21:14:54 curt
119 // Rewrote event.cxx in C++ as a class using STL for the internal event list
120 // and run queue this removes the arbitrary list sizes and makes things much
121 // more dynamic. Because this is C++-classified we can now have multiple
122 // event_tables if we'd ever want them.
124 // Revision 1.1 1998/04/24 00:52:26 curt
125 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
127 // Separated out lighting calcs into their own file.
129 // Revision 1.4 1998/04/21 17:01:43 curt
130 // Fixed a problems where a pointer to a function was being passed around. In
131 // one place this functions arguments were defined as ( void ) while in another
132 // place they were defined as ( int ). The correct answer was ( int ).
134 // Prepairing for C++ integration.
136 // Revision 1.3 1998/01/22 02:59:43 curt
137 // Changed #ifdef FILE_H to #ifdef _FILE_H
139 // Revision 1.2 1998/01/19 18:40:39 curt
140 // Tons of little changes to clean up the code and to remove fatal errors
141 // when building with the c++ compiler.
143 // Revision 1.1 1997/12/30 04:19:22 curt