source: XIOS/dev/dev_trunk_omp/src/filter/garbage_collector.hpp @ 1680

Last change on this file since 1680 was 1680, checked in by yushan, 5 years ago

MARK: Dynamic workflow graph developement. Branch up to date with trunk @1676. Arithmetic filter unified

File size: 2.1 KB
Line 
1#ifndef __XIOS_CGarbageCollector__
2#define __XIOS_CGarbageCollector__
3
4#include <map>
5#include <set>
6
7#include "date.hpp"
8
9namespace xios
10{
11  /*!
12   * Interface shared by all objects that might need to invalidate packets.
13   */
14  struct InvalidableObject
15  {
16    /*!
17     * Removes all pending packets which are older than the specified timestamp.
18     *
19     * \param timestamp the timestamp used for invalidation
20     */
21    void virtual invalidate(Time timestamp) = 0;
22 
23   
24
25    static int filterIdGenerator;
26    #pragma omp threadprivate(filterIdGenerator)
27
28    static int edgeIdGenerator;
29    #pragma omp threadprivate(edgeIdGenerator)
30
31    static int clusterIdGenerator;
32    #pragma omp threadprivate(clusterIdGenerator)
33
34   
35   
36  }; // struct InvalidableObject
37
38  /*!
39   * A basic garbage collector which ensures no old packets linger in the filter graph.
40   */
41  class CGarbageCollector
42  {
43    public:
44      /*!
45       * Constructs a garbage collector.
46       */
47      CGarbageCollector()
48      { /* Nothing to do */ };
49
50      /*!
51       * Registers an object for a specified timestamp.
52       *
53       * \param object the object to register
54       * \param timestamp the timestamp for which the object is registered
55       */
56      void registerObject(InvalidableObject* object, Time timestamp);
57
58      /*!
59       * Removes a object previously registered for a specified timestamp.
60       *
61       * \param object the object to unregister
62       * \param timestamp the timestamp for which the object is unregistered
63       */
64      void unregisterObject(InvalidableObject* object, Time timestamp);
65
66      /*!
67       * Ensures all registered objects invalidate packets older than the specified timestamp.
68       *
69       * \param timestamp the timestamp used for invalidation
70       */
71      void invalidate(Time timestamp);
72
73    private:
74      CGarbageCollector(const CGarbageCollector&);
75      CGarbageCollector& operator=(const CGarbageCollector&);
76
77      std::map<Time, std::set<InvalidableObject*> > registeredObjects; //!< Currently registered objects
78  }; // class CGarbageCollector
79} // namespace xios
80
81#endif //__XIOS_CGarbageCollector__
Note: See TracBrowser for help on using the repository browser.