|
|
|||
File indexing completed on 2026-04-17 08:35:01
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one 0003 * or more contributor license agreements. See the NOTICE file 0004 * distributed with this work for additional information 0005 * regarding copyright ownership. The ASF licenses this file 0006 * to you under the Apache License, Version 2.0 (the 0007 * "License"); you may not use this file except in compliance 0008 * with the License. You may obtain a copy of the License at 0009 * 0010 * http://www.apache.org/licenses/LICENSE-2.0 0011 * 0012 * Unless required by applicable law or agreed to in writing, 0013 * software distributed under the License is distributed on an 0014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 0015 * KIND, either express or implied. See the License for the 0016 * specific language governing permissions and limitations 0017 * under the License. 0018 */ 0019 0020 #ifndef _THRIFT_CONCURRENCY_THREADFACTORY_H_ 0021 #define _THRIFT_CONCURRENCY_THREADFACTORY_H_ 1 0022 0023 #include <thrift/concurrency/Thread.h> 0024 0025 #include <memory> 0026 namespace apache { 0027 namespace thrift { 0028 namespace concurrency { 0029 0030 /** 0031 * Factory to create thread object and bind them to Runnable 0032 * object for execution 0033 */ 0034 class ThreadFactory { 0035 public: 0036 /** 0037 * All threads created by a factory are reference-counted 0038 * via std::shared_ptr. The factory guarantees that threads and the Runnable tasks 0039 * they host will be properly cleaned up once the last strong reference 0040 * to both is given up. 0041 * 0042 * By default threads are not joinable. 0043 */ 0044 ThreadFactory(bool detached = true) : detached_(detached) { } 0045 0046 virtual ~ThreadFactory() = default; 0047 0048 /** 0049 * Gets current detached mode 0050 */ 0051 bool isDetached() const { return detached_; } 0052 0053 /** 0054 * Sets the detached disposition of newly created threads. 0055 */ 0056 void setDetached(bool detached) { detached_ = detached; } 0057 0058 /** 0059 * Create a new thread. 0060 */ 0061 virtual std::shared_ptr<Thread> newThread(std::shared_ptr<Runnable> runnable) const; 0062 0063 /** 0064 * Gets the current thread id or unknown_thread_id if the current thread is not a thrift thread 0065 */ 0066 Thread::id_t getCurrentThreadId() const; 0067 0068 private: 0069 bool detached_; 0070 }; 0071 0072 } 0073 } 0074 } // apache::thrift::concurrency 0075 0076 #endif // #ifndef _THRIFT_CONCURRENCY_THREADFACTORY_H_
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|