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
RevLine 
[639]1#ifndef __XIOS_CGarbageCollector__
2#define __XIOS_CGarbageCollector__
3
4#include <map>
5#include <set>
6
[1021]7#include "date.hpp"
[639]8
9namespace xios
10{
11  /*!
[1021]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;
[1668]22 
23   
[1677]24
25    static int filterIdGenerator;
26    #pragma omp threadprivate(filterIdGenerator)
27
[1679]28    static int edgeIdGenerator;
29    #pragma omp threadprivate(edgeIdGenerator)
30
[1680]31    static int clusterIdGenerator;
32    #pragma omp threadprivate(clusterIdGenerator)
33
[1677]34   
35   
[1021]36  }; // struct InvalidableObject
37
38  /*!
[639]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      /*!
[1021]51       * Registers an object for a specified timestamp.
[639]52       *
[1021]53       * \param object the object to register
54       * \param timestamp the timestamp for which the object is registered
[639]55       */
[1021]56      void registerObject(InvalidableObject* object, Time timestamp);
[639]57
58      /*!
[1021]59       * Removes a object previously registered for a specified timestamp.
[639]60       *
[1021]61       * \param object the object to unregister
62       * \param timestamp the timestamp for which the object is unregistered
[639]63       */
[1021]64      void unregisterObject(InvalidableObject* object, Time timestamp);
[639]65
66      /*!
[1021]67       * Ensures all registered objects invalidate packets older than the specified timestamp.
[639]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
[1021]77      std::map<Time, std::set<InvalidableObject*> > registeredObjects; //!< Currently registered objects
[639]78  }; // class CGarbageCollector
79} // namespace xios
80
81#endif //__XIOS_CGarbageCollector__
Note: See TracBrowser for help on using the repository browser.