Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
thrift-thread.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef IMPALA_RPC_THRIFT_THREAD_H
16 #define IMPALA_RPC_THRIFT_THREAD_H
17 
23 #define HAVE_PTHREAD_H
24 
25 #include <thrift/concurrency/Thread.h>
26 
27 #include "common/logging.h"
28 #include "util/thread.h"
29 #include "util/promise.h"
30 
34 namespace impala {
35 
39  public:
42  ThriftThreadFactory(const std::string& group, const std::string& prefix)
43  : group_(group), prefix_(prefix), count_(0) { }
44 
46  virtual boost::shared_ptr<apache::thrift::concurrency::Thread> newThread(
47  boost::shared_ptr<apache::thrift::concurrency::Runnable> runnable) const;
48 
51  virtual apache::thrift::concurrency::Thread::id_t getCurrentThreadId() const;
52 
53  private:
55  std::string group_;
56 
58  std::string prefix_;
59 
62  mutable int64_t count_;
63 };
64 
68  public:
69  ThriftThread(const std::string& group, const std::string& name,
70  boost::shared_ptr<apache::thrift::concurrency::Runnable> runnable);
71 
74  virtual void start();
75 
77  virtual void join();
78 
80  virtual id_t getId();
81 
82  virtual ~ThriftThread() { }
83 
84  private:
88  void RunRunnable(boost::shared_ptr<apache::thrift::concurrency::Runnable> runnable,
90 
93  boost::scoped_ptr<impala::Thread> impala_thread_;
94 
96  apache::thrift::concurrency::Thread::id_t tid_;
97 
99  std::string group_;
100 
102  std::string name_;
103 };
104 
105 }
106 
107 #endif
virtual void start()
ThriftThread(const std::string &group, const std::string &name, boost::shared_ptr< apache::thrift::concurrency::Runnable > runnable)
virtual apache::thrift::concurrency::Thread::id_t getCurrentThreadId() const
virtual id_t getId()
Returns the Thrift thread ID of the execution thread.
std::string prefix_
Thread name prefix for the Impala ThreadManager.
Definition: thrift-thread.h:58
virtual boost::shared_ptr< apache::thrift::concurrency::Thread > newThread(boost::shared_ptr< apache::thrift::concurrency::Runnable > runnable) const
(From ThreadFactory) - creates a new ThriftThread to run the supplied Runnable.
boost::scoped_ptr< impala::Thread > impala_thread_
Definition: thrift-thread.h:93
void RunRunnable(boost::shared_ptr< apache::thrift::concurrency::Runnable > runnable, Promise< apache::thrift::concurrency::Thread::id_t > *promise)
std::string name_
Individual thread name for the Impala ThreadManager.
apache::thrift::concurrency::Thread::id_t tid_
Thrift thread ID, set by RunRunnable.
Definition: thrift-thread.h:96
std::string group_
Group name for the Impala ThreadManager.
Definition: thrift-thread.h:99
virtual void join()
Joins the separate thread.
string name
Definition: cpu-info.cc:50
ThriftThreadFactory(const std::string &group, const std::string &prefix)
Definition: thrift-thread.h:42
std::string group_
Group name for the Impala ThreadManager.
Definition: thrift-thread.h:55