client-cpp
0.10.0
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
AbstractExecutorContext.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 ABSTRACTEXECUTORCONTEXT_HPP_
18
#define ABSTRACTEXECUTORCONTEXT_HPP_
19
20
#include <memory>
21
22
#include "
kaa/KaaThread.hpp
"
23
#include "
kaa/utils/ThreadPool.hpp
"
24
#include "
kaa/context/IExecutorContext.hpp
"
25
26
namespace
kaa {
27
28
class
AbstractExecutorContext
:
public
IExecutorContext
{
29
public
:
30
AbstractExecutorContext
()
31
: useCount_(0), awaitTerminationTimeout_(5)
32
{}
33
34
virtual
void
init
();
35
virtual
void
stop
();
36
37
void
setAwaitTerminationTimeout
(std::size_t awaitTerminationTimeout)
38
{
39
awaitTerminationTimeout_ = awaitTerminationTimeout;
40
}
41
42
std::size_t
getAwaitTerminationTimeout
()
43
{
44
return
awaitTerminationTimeout_;
45
}
46
47
protected
:
48
virtual
void
doInit
() = 0;
49
virtual
void
doStop
() = 0;
50
51
protected
:
52
IThreadPoolPtr
createExecutor
(std::size_t threadCount)
53
{
54
return
std::make_shared<ThreadPool>(threadCount);
55
}
56
57
void
shutdownExecutor
(
IThreadPoolPtr
threadPool)
58
{
59
if
(threadPool) {
60
threadPool->shutdown();
61
threadPool->awaitTermination(awaitTerminationTimeout_);
62
}
63
}
64
65
private
:
66
std::size_t useCount_;
67
KAA_MUTEX_DECLARE(useCountGuard_);
68
69
std::size_t awaitTerminationTimeout_;
// in seconds
70
};
71
72
}
/* namespace kaa */
73
74
#endif
/* ABSTRACTEXECUTORCONTEXT_HPP_ */
kaa::AbstractExecutorContext::setAwaitTerminationTimeout
void setAwaitTerminationTimeout(std::size_t awaitTerminationTimeout)
Definition:
AbstractExecutorContext.hpp:37
kaa::AbstractExecutorContext::doInit
virtual void doInit()=0
kaa::AbstractExecutorContext::shutdownExecutor
void shutdownExecutor(IThreadPoolPtr threadPool)
Definition:
AbstractExecutorContext.hpp:57
kaa::AbstractExecutorContext::init
virtual void init()
kaa::IThreadPoolPtr
std::shared_ptr< IThreadPool > IThreadPoolPtr
Definition:
IThreadPool.hpp:68
kaa::IExecutorContext
Definition:
IExecutorContext.hpp:26
IExecutorContext.hpp
kaa::AbstractExecutorContext::AbstractExecutorContext
AbstractExecutorContext()
Definition:
AbstractExecutorContext.hpp:30
kaa::AbstractExecutorContext::doStop
virtual void doStop()=0
kaa::AbstractExecutorContext
Definition:
AbstractExecutorContext.hpp:28
kaa::AbstractExecutorContext::getAwaitTerminationTimeout
std::size_t getAwaitTerminationTimeout()
Definition:
AbstractExecutorContext.hpp:42
kaa::AbstractExecutorContext::createExecutor
IThreadPoolPtr createExecutor(std::size_t threadCount)
Definition:
AbstractExecutorContext.hpp:52
kaa::AbstractExecutorContext::stop
virtual void stop()
KaaThread.hpp
ThreadPool.hpp
architec
Documents
kaa
client
client-multi
client-cpp
kaa
context
AbstractExecutorContext.hpp
Generated on Mon Oct 31 2016 16:51:43 for client-cpp by
1.8.6