VR-Forces 4.1 Class Documentation
unusedFeatureTileTracker.h
Go to the documentation of this file.
1 
2 
3 
4 
5 #pragma once
6 
8 
9 #include <boost/optional.hpp>
10 #include <list>
11 
12 #include <tbb/spin_rw_mutex.h>
13 #include <tbb/tbb_thread.h>
14 
15 namespace MAKVRinTerra
16 {
28  {
29  public:
32 
33  typedef boost::shared_ptr<DtUnusedFeatureTileTracker> Ptr;
34  typedef boost::weak_ptr<DtUnusedFeatureTileTracker> WeakPtr;
35  typedef boost::shared_ptr<Trackable> TrackablePtr;
36  typedef std::list<TrackablePtr> TrackableList;
37 
42  DtUnusedFeatureTileTracker(unsigned maxSize = 500000);
43 
47 
49  void start();
50 
52  unsigned length() const;
53 
55  unsigned size() const;
56 
58  void setMaxSize(unsigned max);
59 
61  void unloadUntilSize(unsigned maxSize);
62 
63  private:
64  friend class Trackable;
65 
66  typedef tbb::spin_rw_mutex Mutex;
67 
69  bool add(Trackable&);
70 
72  bool remove(Trackable&);
73 
75  void run();
76 
77  mutable Mutex myMutex;
79 
80  bool myDoneFlag;
81  unsigned myMaxSize;
82  boost::scoped_ptr<tbb::tbb_thread> myPageOutThread;
83  };
84 
86  class DtUnusedFeatureTileTracker::Trackable : private boost::noncopyable
87  {
88  public:
90  virtual ~Trackable();
91 
94  virtual bool keep() const = 0;
95 
97  virtual void load() = 0;
98 
100  virtual void unload() = 0;
101 
105  virtual unsigned size() const = 0;
106 
112  virtual boost::shared_ptr<Trackable> getPtr() = 0;
113 
116  boost::shared_ptr<Sentinel> getSentinel();
117 
119  unsigned useCount() const;
120 
121  protected:
123 
124  private:
126  friend class Sentinel;
127 
128  typedef tbb::spin_rw_mutex Mutex;
129 
131  void sentinelDestroyed();
132 
134  bool hasIterator() const { return myIterator; }
135  TrackableList::iterator iterator() const { return *myIterator; }
136 
137  mutable Mutex myMutex;
138 
140 
142  boost::weak_ptr<Sentinel> mySentinel;
143  boost::optional<TrackableList::iterator> myIterator;
144  };
145 
146  class DtUnusedFeatureTileTracker::Sentinel : private boost::noncopyable
147  {
148  public:
149  typedef boost::shared_ptr<Sentinel> Ptr;
150 
151  ~Sentinel();
152 
153  private:
154  friend class Trackable;
155 
156  Sentinel(boost::shared_ptr<Trackable>);
157 
158  boost::shared_ptr<Trackable> myTrackable;
159  };
160 }

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)