VR-Forces 4.2 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
include
vrfutil
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/spin_mutex.h>
22
23
#include <boost/shared_ptr.hpp>
24
#include <boost/weak_ptr.hpp>
25
26
class
DtAsyncJob
;
27
class
DtAsyncJobMapEntry
;
28
29
enum
DtAsyncJobStatus
30
{
31
queued
,
32
processing
,
33
complete
,
34
canceled
,
35
error
36
};
37
38
39
#include <
vrfutil/vrfutilDefines.h
>
40
class
DT_DLL_vrfutil
DtAsyncJobResult
41
{
42
public
:
43
DtAsyncJobResult
() {};
44
45
virtual
~DtAsyncJobResult
() {};
46
};
47
49
struct
MyHashCompare
50
{
51
static
size_t
hash
(
const
size_t
& x )
52
{
53
return
x;
54
}
55
56
static
bool
equal
(
const
size_t
& x,
const
size_t
& y )
57
{
58
return
x==y;
59
}
60
};
61
62
64
typedef
tbb::concurrent_hash_map<size_t, boost::weak_ptr<DtAsyncJobMapEntry>,
MyHashCompare
>
DtAsyncJobMap
;
65
69
class
DT_DLL_vrfutil
DtAsyncJobServer
70
{
71
public
:
73
DtAsyncJobServer
();
74
76
virtual
~
DtAsyncJobServer
();
77
80
virtual
boost::shared_ptr<DtAsyncJobMapEntry> addJob(
DtAsyncJob
* job);
81
83
virtual
void
cancelAllJobs();
84
86
virtual
bool
empty()
const
;
87
89
virtual
bool
running()
const
;
90
92
virtual
void
printAsyncJobMap();
93
94
protected
:
95
friend
class
DtAsyncJobMapEntry
;
96
friend
class
DtAsyncJob
;
97
99
virtual
size_t
getNextId();
100
102
virtual
void
remove
(
size_t
id);
103
105
virtual
void
jobDestroyed(
DtAsyncJob
&);
106
107
DtAsyncJobMap
myAsyncJobMap
;
108
109
mutable
tbb::spin_mutex
myIdGenMutex
;
110
size_t
myNextId
;
111
112
mutable
tbb::spin_mutex
myNumTasksMutex
;
113
size_t
myNumTasks
;
114
};
115
Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (
www.mak.com
)