VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
asyncJobServer.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright 2015 VT MAK
3 *******************************************************************************/
4 
7 
8 #pragma once
9 
10 #include <vrfutil/vrfutilDefines.h>
11 
12 #include <stdlib.h>
13 #include <memory>
14 #include <list>
15 
17 #include <tbb/concurrent_hash_map.h>
18 #include <tbb/spin_mutex.h>
19 #ifdef WIN32
20  #include <WinSock2.h>
21 #endif
22 
23 #include <boost/shared_ptr.hpp>
24 #include <boost/weak_ptr.hpp>
25 #include <boost/noncopyable.hpp>
26 
27 #include <vrfutil/objectCounter.h>
28 
29 class DtAsyncJob;
30 class DtAsyncJobMapEntry;
31 
34 {
40 };
41 
44  : public DtObjectDebugger<DtAsyncJobResult>
45 {
46 public:
47  virtual ~DtAsyncJobResult();
48 };
49 
51 
54 {
55  static size_t hash( const size_t& x )
56  {
57  return x;
58  }
59 
60  static bool equal( const size_t& x, const size_t& y )
61  {
62  return x==y;
63  }
64 };
65 
66 
68 typedef tbb::concurrent_hash_map<size_t, boost::weak_ptr<DtAsyncJobMapEntry>, MyHashCompare> DtAsyncJobMap;
69 
74 {
75 public:
78 
80  virtual ~DtAsyncJobServer();
81 
88  virtual boost::shared_ptr<DtAsyncJobMapEntry> addJob(DtAsyncJob* job);
89 
91  virtual void cancelAllJobs();
92 
94  virtual void cancelAllJobsAndWait();
95 
97  virtual bool empty() const;
98 
100  virtual bool running() const;
101 
103  virtual void printAsyncJobMap();
104 
106  virtual void tick();
107 
108 protected:
109  friend class DtAsyncJobMapEntry;
110  friend class DtAsyncJob;
111 
112  typedef tbb::spin_mutex Mutex;
113 
115  virtual size_t getNextId();
116 
118  virtual void remove(size_t id);
119 
121  virtual void jobDestroyed(DtAsyncJob&);
122 
124 
126  size_t myNextId;
127 
129  size_t myNumTasks;
130 
131  typedef std::list<DtAsyncJob*> JobList;
134 
135  class DT_DLL_vrfutil JobListScopeGuard : boost::noncopyable
136  {
137  public:
140 
141  private:
143  JobList::iterator i;
144  };
145 };
146 

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)