00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CJNP_COLLECTION_H_
00020 #define __CJNP_COLLECTION_H_ 1
00021
00022 #include <vector>
00023 #include <functional>
00024 #include <boost/shared_ptr.hpp>
00025 #include "CjNetworkProcess.hh"
00026
00027 namespace jmitie {
00028
00029 class CjNP_collection {
00030 public:
00031 typedef boost::shared_ptr<CjNetworkProcess> procEntry_t;
00032 typedef std::vector< procEntry_t > procList_t;
00033
00034 protected:
00035 unsigned int m_epoch;
00036 unsigned int m_clearout_period;
00037 mutable bool m_active_list_valid;
00038 bool m_assume_all_active;
00039 procList_t m_master_list;
00040
00041 mutable procList_t m_active_list;
00042 procList_t m_end_list;
00043
00044 struct priolist_cmp_lt : public std::binary_function<procEntry_t, procEntry_t, bool> {
00045 bool operator()( const procEntry_t & lhs, const procEntry_t & rhs ) { return lhs->getProcessPriority() < rhs->getProcessPriority(); }
00046 };
00047
00048 public:
00049 CjNP_collection(unsigned int clearout_period = 50, bool assume_all_active = false);
00050 unsigned int setClearoutPeriod(unsigned int period);
00051 unsigned int getClearoutPeriod() const;
00052 void clear();
00053 void append( procEntry_t & proc);
00054 CjNP_collection::procList_t::size_type size() const;
00055 CjNP_collection::procList_t::size_type endlist_size() const;
00056 unsigned int incrementEpoch();
00057 unsigned int getEpoch() const;
00058 CjNP_collection::procList_t get_epochBundle() const;
00059 CjNP_collection::procList_t get_endBundle() const;
00060 bool allExpired() const;
00061
00062 };
00063
00064 }
00065
00066 #endif // __CJNP_COLLECTION_H_
00067