VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtBackgroundLoader.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * Copyright (c) 2020 MAK Technologies, Inc.
3 * All rights reserved.
4 *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/vrvCore.h>
13 
15 
16 #include <tbb/atomic.h>
17 #include <tbb/task.h>
18 
19 #include <boost/thread.hpp>
20 #include <boost/unordered_map.hpp>
21 
22 // FIXME:
23 // This should not be in vrvCore!!
24 namespace osgUtil
25 {
26  class StateToCompile;
27 }
28 
29 namespace makVrv
30 {
31  class DtDe;
32  class DtModel;
33  class DtBackgroundLoader;
34  struct DtLoaderHandle;
35 
39  {
40  public:
42  virtual ~DtBackgroundLoader();
43 
46  static DtBackgroundLoader& instance(DtDe& de);
47 
48  static void registerInstance(DtDe& de, DtBackgroundLoader *manager);
49 
51  static const std::string& theClassName();
52 
55  virtual void updateQueue(int max_thread_count, int active_threads);
56 
58  virtual DtLoaderHandle* queueForLoad(DtModel* object);
59 
64  virtual void setForegroundTimeBudget(double budget);
65 
67  virtual void incrementForegroundTime(double time_elapse);
68 
70  virtual bool isForegroundTimeBudgetExpired() const;
71 
73  virtual double timeSpentThisFrame() const;
75 
78  virtual void loadIfPossibleOrAddToQueue(DtModel* object);
80  virtual bool hasActiveAsyncTasks() const;
81 
83  virtual int numModelDefinitionsToIco() const;
85  virtual std::string nextModelDefinitionToIco();
86 
88  virtual int numOfActiveTasks() const;
89 
91  virtual void addToAdditionalIcoList(osgUtil::StateToCompile* compile);
93  virtual std::list<osgUtil::StateToCompile*>& additionalToIcoList();
94 
96  virtual bool multithreadedLoadingActive() const;
98  virtual void setMultithreadedLoadingActive(bool val);
99 
101  DtDe& de() { return myDe; }
102 
103  protected:
104 
106 
108  virtual void timedForegroundLoad(DtModel* object);
109 
110  virtual void ts_setModelDefinitionLoaded(const std::string& modelDefinition);
111  virtual bool ts_isModelDefinitionLoaded(const std::string& modelDefinition) const;
112 
114 
115  boost::mutex myProducerQueueMutex;
116  std::list< DtLoaderHandle* > myProducerQueue;
117  std::list< DtLoaderHandle* > myForegroundQueue;
118  std::list< std::string > myModelDefsToIcoQueue;
119 
120  std::list<DtLoaderHandle* > myObjectsFinishedWithTBBTask;
121  std::list<osgUtil::StateToCompile* > myAdditionalToIcoList;
122 
123  boost::mutex myTaskFinishedMutex;
124  std::list<DtLoaderHandle* > myObjectsToForegroundLoad;
125 
126  std::map<std::string, bool> myActivelyLoadingModelDefs;
127  tbb::atomic<int> myNumberOfActiveTasks;
128 
130  mutable boost::mutex myMutableLoadedDefMapMutex;
131  boost::unordered_map<std::string, bool> myLoadedDefMap;
132 
135 
136  };
137 
138 
139 };
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
std::map< std::string, bool > myActivelyLoadingModelDefs
Definition: DtBackgroundLoader.h:126
std::list< DtLoaderHandle * > myForegroundQueue
Definition: DtBackgroundLoader.h:117
async task that loads a DtModel in the background
Definition: DtBackgroundLoadAsyncTask.h:25
core singleton that manages loading for all the various DtModel subclasses
Definition: DtBackgroundLoader.h:38
boost::unordered_map< std::string, bool > myLoadedDefMap
Definition: DtBackgroundLoader.h:131
boost::mutex myMutableLoadedDefMapMutex
Definition: DtBackgroundLoader.h:130
bool myMultithreadedLoadingActive
Definition: DtBackgroundLoader.h:134
tbb::atomic< int > myNumberOfActiveTasks
Definition: DtBackgroundLoader.h:127
DtDe & myDe
Definition: DtBackgroundLoader.h:105
double myForegroundTimeBudget
Definition: DtBackgroundLoader.h:133
Contains makVrv::DtVirtualBaseClass class.
boost::mutex myTaskFinishedMutex
Definition: DtBackgroundLoader.h:123
wrapper object that insulates the loader from other threads destroying an object
Definition: DtLoaderHandle.h:23
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
std::list< osgUtil::StateToCompile * > myAdditionalToIcoList
Definition: DtBackgroundLoader.h:121
std::list< std::string > myModelDefsToIcoQueue
Definition: DtBackgroundLoader.h:118
std::list< DtLoaderHandle * > myObjectsToForegroundLoad
Definition: DtBackgroundLoader.h:124
std::list< DtLoaderHandle * > myProducerQueue
Definition: DtBackgroundLoader.h:116
A model which owns a single model instance. A DtModel is a managing container for a single DtModelIns...
Definition: DtModel.h:55
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
std::list< DtLoaderHandle * > myObjectsFinishedWithTBBTask
Definition: DtBackgroundLoader.h:120
boost::mutex myProducerQueueMutex
Definition: DtBackgroundLoader.h:115
double myTimeSpentThisFrame
Definition: DtBackgroundLoader.h:129
DtDe & de()
returns the de
Definition: DtBackgroundLoader.h:101
Contains DLL export macros.

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)