1 // Created on: 2015-05-29
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <BVH_BuildThread.hxx>
18 IMPLEMENT_STANDARD_RTTIEXT(BVH_BuildThread,Standard_Transient)
20 // =======================================================================
21 // function : BVH_BuildThread
22 // purpose : Creates new BVH build thread
23 // =======================================================================
24 BVH_BuildThread::BVH_BuildThread (BVH_BuildTool& theBuildTool,
25 BVH_BuildQueue& theBuildQueue)
26 : myBuildTool (theBuildTool),
27 myBuildQueue (theBuildQueue),
28 myWorkThread (threadFunction)
33 // =======================================================================
35 // purpose : Executes BVH build thread
36 // =======================================================================
37 void BVH_BuildThread::execute()
39 for (Standard_Boolean wasBusy = Standard_False; /**/; /**/)
41 const Standard_Integer aNode = myBuildQueue.Fetch (wasBusy);
43 if (aNode == -1) // queue is empty
45 if (!myBuildQueue.HasBusyThreads())
47 break; // no active threads
52 myBuildTool.Perform (aNode);
57 // =======================================================================
58 // function : threadFunction
59 // purpose : Thread function for BVH build thread
60 // =======================================================================
61 Standard_Address BVH_BuildThread::threadFunction (Standard_Address theData)
63 static_cast<BVH_BuildThread*> (theData)->execute();