VR-Forces 4.6 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
include
vrfutil
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
33
enum
DtAsyncJobStatus
34
{
35
queued
,
36
processing
,
37
complete
,
38
canceled
,
39
error
40
};
41
43
class
DT_DLL_vrfutil
DtAsyncJobResult
44
:
public
DtObjectDebugger
<DtAsyncJobResult>
45
{
46
public
:
47
virtual
~
DtAsyncJobResult
();
48
};
49
50
DT_DEFINE_OBJECT_DEBUGGER_NAME
(
DtAsyncJobResult
);
51
53
struct
MyHashCompare
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
73
class
DT_DLL_vrfutil
DtAsyncJobServer
74
{
75
public
:
77
DtAsyncJobServer
();
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
123
DtAsyncJobMap
myAsyncJobMap
;
124
125
mutable
Mutex
myIdGenMutex
;
126
size_t
myNextId
;
127
128
mutable
Mutex
myNumTasksMutex
;
129
size_t
myNumTasks
;
130
131
typedef
std::list<DtAsyncJob*>
JobList
;
132
mutable
Mutex
myJobListMutex
;
133
JobList
myCurrentJobs
;
134
135
class
DT_DLL_vrfutil
JobListScopeGuard
: boost::noncopyable
136
{
137
public
:
138
JobListScopeGuard
(
DtAsyncJobServer
& server,
DtAsyncJob
& job);
139
~
JobListScopeGuard
();
140
141
private
:
142
DtAsyncJobServer
&
server
;
143
JobList::iterator
i
;
144
};
145
};
146
Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (
www.mak.com
)