forked from mattjr/structured
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckThreadPool.cpp
More file actions
97 lines (78 loc) · 2.95 KB
/
CheckThreadPool.cpp
File metadata and controls
97 lines (78 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// structured - Tools for the Generation and Visualization of Large-scale
// Three-dimensional Reconstructions from Image Data. This software includes
// source code from other projects, which is subject to different licensing,
// see COPYING for details. If this project is used for research see COPYING
// for making the appropriate citations.
// Copyright (C) 2013 Matthew Johnson-Roberson <mattkjr@gmail.com>
//
// This file is part of structured.
//
// structured is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// structured is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with structured. If not, see <http://www.gnu.org/licenses/>.
//
#include "CheckThreadPool.h"
void CheckThreadPool::init(void)
{
_numRunningOperations = 0;
_done = false;
_operationQueue = new osg::OperationQueue;
_blockOp = new vpb::BlockOperation;
osg::GraphicsContext* sharedContext = 0;
_maxNumberOfOperationsInQueue = 64;
for(unsigned int i=0; i<_numThreads; ++i)
{
osg::ref_ptr<osg::OperationThread> thread;
osg::ref_ptr<osg::GraphicsContext> gc;
if (_requiresGraphicsContext)
{
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 0;
traits->y = 0;
traits->width = 1;
traits->height = 1;
traits->windowDecoration = false;
traits->doubleBuffer = false;
traits->sharedContext = sharedContext;
traits->pbuffer = true;
gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!gc)
{
traits->pbuffer = false;
gc = osg::GraphicsContext::createGraphicsContext(traits.get());
}
if (gc.valid())
{
gc->realize();
if (!sharedContext) sharedContext = gc.get();
gc->createGraphicsThread();
thread = gc->getGraphicsThread();
}else{
printf("CHECK TP override: Failed to create graphics thread\n");
haveWorkingContext=false;
thread = new osg::OperationThread;
thread->setParent(this);
}
}
else
{
thread = new osg::OperationThread;
thread->setParent(this);
}
if (thread.valid())
{
thread->setOperationQueue(_operationQueue.get());
_threads.push_back(ThreadContextPair(thread, gc));
}
}
}