65578e1c |
1 | // Created on: 2015-05-28 |
2 | // Created by: Denis BOGOLEPOV |
3 | // Copyright (c) 2015 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 | #ifndef _BVH_BuildQueue_Header |
17 | #define _BVH_BuildQueue_Header |
18 | |
19 | #include <BVH_Builder.hxx> |
20 | |
21 | #include <Standard_Mutex.hxx> |
22 | #include <NCollection_Sequence.hxx> |
23 | |
24 | //! Command-queue for parallel building of BVH nodes. |
25 | class BVH_BuildQueue |
26 | { |
27 | template <class T, int N> friend class BVH_QueueBuilder; |
28 | |
29 | public: |
30 | |
31 | //! Creates new BVH build queue. |
32 | BVH_BuildQueue() |
33 | : myNbThreads (0) |
34 | { |
35 | // |
36 | } |
37 | |
38 | //! Releases resources of BVH build queue. |
39 | ~BVH_BuildQueue() |
40 | { |
41 | // |
42 | } |
43 | |
44 | public: |
45 | |
46 | //! Returns current size of BVH build queue. |
47 | Standard_EXPORT Standard_Integer Size(); |
48 | |
49 | //! Enqueues new work-item onto BVH build queue. |
50 | Standard_EXPORT void Enqueue (const Standard_Integer& theNode); |
51 | |
52 | //! Fetches first work-item from BVH build queue. |
53 | Standard_EXPORT Standard_Integer Fetch (Standard_Boolean& wasBusy); |
54 | |
55 | //! Checks if there are active build threads. |
56 | Standard_Boolean HasBusyThreads() |
57 | { |
58 | return myNbThreads != 0; |
59 | } |
60 | |
61 | protected: |
62 | |
63 | //! Queue of BVH nodes to build. |
64 | NCollection_Sequence<Standard_Integer> myQueue; |
65 | |
66 | protected: |
67 | |
68 | //! Manages access serialization of working threads. |
69 | Standard_Mutex myMutex; |
70 | |
71 | //! Number of active build threads. |
72 | Standard_Integer myNbThreads; |
73 | }; |
74 | |
75 | #endif // _BVH_BuildQueue_Header |