source: XIOS/trunk/src/filter/garbage_collector.hpp @ 1006

Last change on this file since 1006 was 1006, checked in by rlacroix, 7 years ago

The workflow is now triggered when using xios_recv_field for fields in read mode received from the servers.

Previously the workflow was triggered upon receiving the data which could cause deadlocks since there are no garanties that clients are receiving data at the same time.

File size: 1.8 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  }; // struct InvalidableObject
23
24  /*!
25   * A basic garbage collector which ensures no old packets linger in the filter graph.
26   */
27  class CGarbageCollector
28  {
29    public:
30      /*!
31       * Constructs a garbage collector.
32       */
33      CGarbageCollector()
34      { /* Nothing to do */ };
35
36      /*!
37       * Registers an object for a specified timestamp.
38       *
39       * \param object the object to register
40       * \param timestamp the timestamp for which the object is registered
41       */
42      void registerObject(InvalidableObject* object, Time timestamp);
43
44      /*!
45       * Removes a object previously registered for a specified timestamp.
46       *
47       * \param object the object to unregister
48       * \param timestamp the timestamp for which the object is unregistered
49       */
50      void unregisterObject(InvalidableObject* object, Time timestamp);
51
52      /*!
53       * Ensures all registered objects invalidate packets older than the specified timestamp.
54       *
55       * \param timestamp the timestamp used for invalidation
56       */
57      void invalidate(Time timestamp);
58
59    private:
60      CGarbageCollector(const CGarbageCollector&);
61      CGarbageCollector& operator=(const CGarbageCollector&);
62
63      std::map<Time, std::set<InvalidableObject*> > registeredObjects; //!< Currently registered objects
64  }; // class CGarbageCollector
65} // namespace xios
66
67#endif //__XIOS_CGarbageCollector__
Note: See TracBrowser for help on using the repository browser.