VR-Forces 4.1.1 Class Documentation
asyncJobServer.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright 2010 VT MAK
3 *******************************************************************************/
4 
5 
8 
9 #pragma once
10 
11 
12 #include <stdlib.h>
13 #include <memory>
14 #include <list>
15 
17 #include <tbb/concurrent_hash_map.h>
18 #ifdef WIN32
19  #include <WinSock2.h>
20 #endif
21 #include <tbb/mutex.h>
22 
23 
24 class DtAsyncJob;
25 class DtAsyncJobToken;
26 class DtAsyncJobMapEntry;
27 
29 {
35 };
36 
37 
38 
39 typedef
41 
42 #include <vrfutil/vrfutilDefines.h>
44 {
45 public:
47 
48  virtual ~DtAsyncJobResult() {};
49 };
50 
53 {
54  static size_t hash( const size_t& x )
55  {
56  return x;
57  }
58 
59  static bool equal( const size_t& x, const size_t& y )
60  {
61  return x==y;
62  }
63 };
64 
65 
67 typedef tbb::concurrent_hash_map<size_t, DtAsyncJobMapEntry*, MyHashCompare> DtAsyncJobMap;
68 
70 {
71 public:
73 
77  const DtAsyncJobResult* lookupAsyncJobResult(size_t id) const;
78 
79  virtual DtAsyncJobToken* addJob(std::auto_ptr<DtAsyncJob> job);
80 
81  virtual void cancelJob(size_t id);
82  virtual void cancelAllJobs();
83  bool empty();
84 
85  static size_t getId();
86 
89  virtual void markForRemoval(size_t id);
90 
91  virtual void cleanUpJobs();
92 
93  virtual DtAsyncJobStatus jobStatus(size_t id);
94 
95  virtual bool accessor(DtAsyncJobMap::accessor& a, size_t id);
96 
98  virtual void printAsyncJobMap();
99 
100 protected:
101 
103 
104  static tbb::mutex theIdGenMutex;
105  static size_t theNextId;
106 
107  static tbb::mutex theJobRemovalQueueMutex;
108  std::list<size_t> myJobsToRemove;
109 };
110 

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)