0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / BVH / BVH_BuildThread.cxx
CommitLineData
65578e1c 1// Created on: 2015-05-29
2// Created by: Denis BOGOLEPOV
3// Copyright (c) 2013-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#include <BVH_BuildThread.hxx>
17
92efcf78 18IMPLEMENT_STANDARD_RTTIEXT(BVH_BuildThread,Standard_Transient)
19
65578e1c 20// =======================================================================
21// function : BVH_BuildThread
22// purpose : Creates new BVH build thread
23// =======================================================================
24BVH_BuildThread::BVH_BuildThread (BVH_BuildTool& theBuildTool,
25 BVH_BuildQueue& theBuildQueue)
26: myBuildTool (theBuildTool),
27 myBuildQueue (theBuildQueue),
28 myWorkThread (threadFunction)
29{
30 //
31}
32
33// =======================================================================
34// function : execute
35// purpose : Executes BVH build thread
36// =======================================================================
37void BVH_BuildThread::execute()
38{
39 for (Standard_Boolean wasBusy = Standard_False; /**/; /**/)
40 {
41 const Standard_Integer aNode = myBuildQueue.Fetch (wasBusy);
42
43 if (aNode == -1) // queue is empty
44 {
45 if (!myBuildQueue.HasBusyThreads())
46 {
47 break; // no active threads
48 }
49 }
50 else
51 {
52 myBuildTool.Perform (aNode);
53 }
54 }
55}
56
57// =======================================================================
58// function : threadFunction
59// purpose : Thread function for BVH build thread
60// =======================================================================
61Standard_Address BVH_BuildThread::threadFunction (Standard_Address theData)
62{
63 static_cast<BVH_BuildThread*> (theData)->execute();
64
65 return NULL;
66}