2
* Licensed to the Apache Software Foundation (ASF) under one
3
* or more contributor license agreements. See the NOTICE file
4
* distributed with this work for additional information
5
* regarding copyright ownership. The ASF licenses this file
6
* to you under the Apache License, Version 2.0 (the
7
* "License"); you may not use this file except in compliance
8
* with the License. You may obtain a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing,
13
* software distributed under the License is distributed on an
14
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
* KIND, either express or implied. See the License for the
16
* specific language governing permissions and limitations
20
#ifndef _THRIFT_CONCURRENCY_BOOSTTHREADFACTORY_H_
21
#define _THRIFT_CONCURRENCY_BOOSTTHREADFACTORY_H_ 1
25
#include <boost/shared_ptr.hpp>
27
namespace apache { namespace thrift { namespace concurrency {
30
* A thread factory to create posix threads
34
class BoostThreadFactory : public ThreadFactory {
39
* Boost thread factory. All threads created by a factory are reference-counted
40
* via boost::shared_ptr and boost::weak_ptr. The factory guarantees that threads and
41
* the Runnable tasks they host will be properly cleaned up once the last strong reference
42
* to both is given up.
44
* Threads are created with the specified boost policy, priority, stack-size. A detachable thread is not
47
* By default threads are not joinable.
50
BoostThreadFactory(bool detached=true);
52
// From ThreadFactory;
53
boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const;
55
// From ThreadFactory;
56
Thread::id_t getCurrentThreadId() const;
59
* Sets detached mode of threads
61
virtual void setDetached(bool detached);
64
* Gets current detached mode
66
virtual bool isDetached() const;
70
boost::shared_ptr<Impl> impl_;
73
}}} // apache::thrift::concurrency
75
#endif // #ifndef _THRIFT_CONCURRENCY_BOOSTTHREADFACTORY_H_