HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ThreadIOPool.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_ThreadIOPool.h
7  *
8  * COMMENTS:
9  *
10  *
11  */
12 
13 #ifndef __UT_THREADIOPOOL_H__
14 #define __UT_THREADIOPOOL_H__
15 
16 #include "UT_API.h"
17 
18 #include "UT_BoostAsio.h"
19 
20 #include "UT_Assert.h"
21 #include "UT_IOContext.h"
22 #include "UT_Lock.h"
23 #include "UT_Thread.h"
24 #include "UT_UniquePtr.h"
25 
26 /// By default only the subsystem should be able to stop the pool. Use
27 /// UT_ThreadIOPool instead of you need control over starting and stopping.
29 {
30 public:
31  UT_PrivateThreadIOPool() = default;
32 
33  ASIO_IOContext::executor_type executor()
34  {
35  return myIOContext.get_executor();
36  }
37 
38  void start(int nthreads);
39 
40 protected:
41  void stop();
42 
43 private:
44  friend class UT_SubSystem;
45 
46  static void runIOContextLoop(UT_PrivateThreadIOPool& pool);
47 
48  mutable UT_Lock myLock;
50  UT_IOContext myIOContext;
51  UT_UniquePtr<hboost::asio::executor_work_guard<
52  hboost::asio::io_context::executor_type>>
53  myIOWorkGuard;
54 };
55 
57 {
58 public:
60 };
61 #endif // __UT_THREADIOPOOL_H__
The subsystem to initialize and cleanup UT.
Definition: UT_SubSystem.h:109
GLuint start
Definition: glcorearb.h:475
#define UT_API
Definition: UT_API.h:14
ASIO_IOContext::executor_type executor()
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
**Note that the tasks the is the thread number *for the pool
Definition: thread.h:637