Remove INJECT_EVENTS permissions from test APKs.
[chromium-blink-merge.git] / third_party / re2 / util / thread.cc
blob7349991530a57011b46b00e5591e229c3797e052
1 // Copyright 2009 The RE2 Authors. All Rights Reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 #include <pthread.h>
7 #include "util/util.h"
8 #include "util/thread.h"
10 Thread::Thread() {
11 pid_ = 0;
12 running_ = 0;
13 joinable_ = 0;
16 Thread::~Thread() {
19 void *startThread(void *v) {
20 Thread* t = (Thread*)v;
21 t->Run();
22 return 0;
25 void Thread::Start() {
26 CHECK(!running_);
27 pthread_create(&pid_, 0, startThread, this);
28 running_ = true;
29 if (!joinable_)
30 pthread_detach(pid_);
33 void Thread::Join() {
34 CHECK(running_);
35 CHECK(joinable_);
36 void *val;
37 pthread_join(pid_, &val);
38 running_ = 0;
41 void Thread::SetJoinable(bool j) {
42 CHECK(!running_);
43 joinable_ = j;