client-cpp  0.9.0
SimpleExecutorContext.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2016 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SIMPLEEXECUTORCONTEXT_HPP_
18 #define SIMPLEEXECUTORCONTEXT_HPP_
19 
20 #include <memory>
21 
23 
24 namespace kaa {
25 
27 public:
28  SimpleExecutorContext(std::size_t lifeCycleThreadCount = DEFAULT_THREAD_COUNT
29  , std::size_t apiThreadCount = DEFAULT_THREAD_COUNT
30  , std::size_t callbackThreadCount = DEFAULT_THREAD_COUNT);
31 
32  virtual IThreadPool& getLifeCycleExecutor() { return *lifeCycleExecutor_; }
33  virtual IThreadPool& getApiExecutor() { return *apiExecutor_; }
34  virtual IThreadPool& getCallbackExecutor() { return *callbackExecutor_; }
35 
36 public:
37  static const std::size_t DEFAULT_THREAD_COUNT = 1;
38 
39 protected:
40  virtual void doInit();
41  virtual void doStop();
42 
43 private:
44  const std::size_t apiThreadCount_;
45  const std::size_t callbackThreadCount_;
46  const std::size_t lifeCycleThreadCount_;
47 
48  IThreadPoolPtr apiExecutor_;
49  IThreadPoolPtr callbackExecutor_;
50  IThreadPoolPtr lifeCycleExecutor_;
51 };
52 
53 } /* namespace kaa */
54 
55 #endif /* SIMPLEEXECUTORCONTEXT_HPP_ */
std::shared_ptr< IThreadPool > IThreadPoolPtr
Definition: IThreadPool.hpp:40
virtual IThreadPool & getApiExecutor()
virtual IThreadPool & getCallbackExecutor()
static const std::size_t DEFAULT_THREAD_COUNT
SimpleExecutorContext(std::size_t lifeCycleThreadCount=DEFAULT_THREAD_COUNT, std::size_t apiThreadCount=DEFAULT_THREAD_COUNT, std::size_t callbackThreadCount=DEFAULT_THREAD_COUNT)
virtual IThreadPool & getLifeCycleExecutor()