Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:18

0001 // Created on: 2015-05-28
0002 // Created by: Denis BOGOLEPOV
0003 // Copyright (c) 2015 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _BVH_BuildQueue_Header
0017 #define _BVH_BuildQueue_Header
0018 
0019 #include <BVH_Builder.hxx>
0020 
0021 #include <Standard_Mutex.hxx>
0022 #include <NCollection_Sequence.hxx>
0023 
0024 //! Command-queue for parallel building of BVH nodes.
0025 class BVH_BuildQueue
0026 {
0027   template <class T, int N> friend class BVH_QueueBuilder;
0028 
0029 public:
0030 
0031   //! Creates new BVH build queue.
0032   BVH_BuildQueue()
0033   : myNbThreads (0)
0034   {
0035     //
0036   }
0037 
0038   //! Releases resources of BVH build queue.
0039   ~BVH_BuildQueue()
0040   {
0041     //
0042   }
0043 
0044 public:
0045 
0046   //! Returns current size of BVH build queue.
0047   Standard_EXPORT Standard_Integer Size();
0048 
0049   //! Enqueues new work-item onto BVH build queue.
0050   Standard_EXPORT void Enqueue (const Standard_Integer& theNode);
0051 
0052   //! Fetches first work-item from BVH build queue.
0053   Standard_EXPORT Standard_Integer Fetch (Standard_Boolean& wasBusy);
0054 
0055   //! Checks if there are active build threads.
0056   Standard_Boolean HasBusyThreads()
0057   {
0058     return myNbThreads != 0;
0059   }
0060 
0061 protected:
0062 
0063   //! Queue of BVH nodes to build.
0064   NCollection_Sequence<Standard_Integer> myQueue;
0065 
0066 protected:
0067 
0068   //! Manages access serialization of working threads.
0069   Standard_Mutex myMutex;
0070 
0071   //! Number of active build threads.
0072   Standard_Integer myNbThreads;
0073 };
0074 
0075 #endif // _BVH_BuildQueue_Header