00001 #ifndef RUNTIME_HISTORY_CLASS 00002 #define RUNTIME_HISTORY_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : runtime_history * 00007 * Author : Chris Koeritz * 00008 * * 00009 ******************************************************************************* 00010 * Copyright (c) 1990-$now By Author. This program is free software; you can * 00011 * redistribute it and/or modify it under the terms of the GNU General Public * 00012 * License as published by the Free Software Foundation; either version 2 of * 00013 * the License or (at your option) any later version. This is online at: * 00014 * http://www.fsf.org/copyleft/gpl.html * 00015 * Please send any updates to: fred@gruntose.com * 00016 \*****************************************************************************/ 00017 00018 #include "opsysdll.h" 00019 00020 #include <basis/packable.h> 00021 00022 const int DEFAULT_RUNTIME_HISTORY = 2000; 00023 00024 // forward. 00025 class mutex; 00026 class occurrence; 00027 class occurrence_list; 00028 00030 00039 class OPSYSTEM_CLASS_STYLE runtime_history : public packable 00040 { 00041 public: 00042 runtime_history(int maximum_length = DEFAULT_RUNTIME_HISTORY); 00043 ~runtime_history(); 00044 00045 void add_outcome(const occurrence &happening); 00047 00049 // note that elements() and get() are thread safe, but unless one locks 00050 // the list, one is not guaranteed that the list of occurrences will not 00051 // change. if you do lock the list, you must unlock it again afterwards. 00052 00053 int elements() const; 00055 00056 const occurrence &get(int index); 00058 00059 void lock(); 00060 void unlock(); 00061 00062 virtual void pack(byte_array &packed_form) const; 00064 virtual bool unpack(byte_array &packed_form); 00066 00067 int max_items() const; 00069 void set_max_items(int new_max); 00071 00072 private: 00073 int _bound; 00074 mutex *_lock; 00075 occurrence_list *_occurrences; 00076 00077 const occurrence &empty_junk_occurrence(); 00078 }; 00079 00080 #endif 00081
1.5.1