source: XIOS/trunk/src/filter/garbage_collector.cpp @ 1293

Last change on this file since 1293 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.1 KB
Line 
1#include "garbage_collector.hpp"
2
3namespace xios
4{
5  void CGarbageCollector::registerObject(InvalidableObject* Object, Time timestamp)
6  {
7    registeredObjects[timestamp].insert(Object);
8  }
9
10  void CGarbageCollector::unregisterObject(InvalidableObject* Object, Time timestamp)
11  {
12    std::map<Time, std::set<InvalidableObject*> >::iterator it = registeredObjects.find(timestamp);
13    if (it != registeredObjects.end())
14      it->second.erase(Object);
15  }
16
17  void CGarbageCollector::invalidate(Time timestamp)
18  {
19    std::map<Time, std::set<InvalidableObject*> >::iterator it    = registeredObjects.begin(),
20                                                            itEnd = registeredObjects.lower_bound(timestamp);
21    for (; it != itEnd; ++it)
22    {
23      std::set<InvalidableObject*>::iterator itObject    = it->second.begin(),
24                                             itObjectEnd = it->second.end();
25      for (; itObject != itObjectEnd; ++itObject)
26        (*itObject)->invalidate(timestamp);
27    }
28    registeredObjects.erase(registeredObjects.begin(), itEnd);
29  }
30} // namespace xios
Note: See TracBrowser for help on using the repository browser.