Remove mozc::DetachedThread as it is no longer used
This is just a removal of dead code. Hence no behavior change is intended.
BUG=none
TEST=unittest
git-svn-id: https://mozc.googlecode.com/svn/trunk@504 a6090854-d499-a067-5803-1114d4e51264
diff --git a/src/base/thread.cc b/src/base/thread.cc
index d6fc816..48a2603 100644
--- a/src/base/thread.cc
+++ b/src/base/thread.cc
@@ -108,7 +108,7 @@
}
}
-#else
+#else // OS_WIN
// Thread implementation for pthread-based platforms. Currently all the
// platforms except for Windows use pthread.
@@ -258,8 +258,7 @@
#endif // OS_WIN
-Thread::Thread()
- : state_(new ThreadInternalState) {}
+Thread::Thread() : state_(new ThreadInternalState) {}
Thread::~Thread() {
Detach();
@@ -269,49 +268,4 @@
state_->joinable_ = joinable;
}
-namespace {
-
-#ifdef OS_WIN
-unsigned __stdcall DetachedThreadFuncWin(void *ptr) {
- scoped_ptr<DetachedThread> p(static_cast<DetachedThread *>(ptr));
- p->Run();
- return 0;
-}
-#else
-void *DetachedThreadFuncPosix(void *ptr) {
- scoped_ptr<DetachedThread> p(static_cast<DetachedThread *>(ptr));
- p->Run();
- return 0;
-}
-#endif // OS_WIN
-
-} // namespace
-
-DetachedThread::DetachedThread() {}
-
-DetachedThread::~DetachedThread() {}
-
-bool DetachedThread::Start() {
-#ifdef OS_WIN
- HANDLE handle = reinterpret_cast<HANDLE>(_beginthreadex(
- NULL, 0, DetachedThreadFuncWin, this, 0, NULL));
- if (0 == handle) {
- delete this;
- return false;
- }
- ::CloseHandle(handle);
- return true;
-#else
- pthread_attr_t tattr;
- pthread_attr_init(&tattr);
- pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
- pthread_t thread_id;
- if (0 != pthread_create(&thread_id, &tattr, DetachedThreadFuncPosix, this)) {
- delete this;
- return false;
- }
- return true;
-#endif // OS_WIN
-}
-
} // namespace mozc
diff --git a/src/base/thread.h b/src/base/thread.h
index 9f3b102..68f6449 100644
--- a/src/base/thread.h
+++ b/src/base/thread.h
@@ -30,7 +30,6 @@
#ifndef MOZC_BASE_THREAD_H_
#define MOZC_BASE_THREAD_H_
-#include "base/compiler_specific.h"
#include "base/port.h"
#include "base/scoped_ptr.h"
@@ -64,17 +63,6 @@
DISALLOW_COPY_AND_ASSIGN(Thread);
};
-class DetachedThread {
- public:
- DetachedThread();
- virtual ~DetachedThread();
- bool Start();
- virtual void Run() = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DetachedThread);
-};
-
} // namespace mozc
#endif // MOZC_BASE_THREAD_H_
diff --git a/src/base/thread_test.cc b/src/base/thread_test.cc
index 7cefe8d..e9e401b 100644
--- a/src/base/thread_test.cc
+++ b/src/base/thread_test.cc
@@ -29,10 +29,6 @@
#include "base/thread.h"
-#include <stdlib.h>
-
-#include "base/mutex.h"
-#include "base/unnamed_event.h"
#include "base/util.h"
#include "testing/base/public/gunit.h"
@@ -41,9 +37,8 @@
class TestThread : public Thread {
public:
- explicit TestThread(int time)
- : time_(time),
- invoked_(false) {}
+ explicit TestThread(int time) : time_(time), invoked_(false) {}
+ virtual ~TestThread() {}
virtual void Run() {
invoked_ = true;
@@ -61,6 +56,7 @@
int time_;
bool invoked_;
};
+
} // namespace
TEST(ThreadTest, BasicThreadTest) {
@@ -118,44 +114,4 @@
}
}
-namespace {
-
-class SampleDetachedThread : public DetachedThread {
- public:
- explicit SampleDetachedThread(int time, Mutex *mutex, bool *done_flag,
- UnnamedEvent *event)
- : mutex_(mutex), time_(time), done_flag_(done_flag), event_(event) {
- }
- virtual ~SampleDetachedThread() {
- scoped_lock l(mutex_);
- *done_flag_ = true;
- event_->Notify();
- }
- virtual void Run() {
- Util::Sleep(time_);
- }
-
- private:
- Mutex *mutex_;
- int time_;
- bool *done_flag_;
- UnnamedEvent *event_;
-};
-
-} // namespace
-
-TEST(DetachedThread, SimpleTest) {
- Mutex mutex;
- UnnamedEvent event;
- bool done_flag = false;
- SampleDetachedThread *thread =
- new SampleDetachedThread(50, &mutex, &done_flag, &event);
- thread->Start();
- ASSERT_TRUE(event.Wait(-1));
- {
- scoped_lock l(&mutex);
- EXPECT_TRUE(done_flag);
- }
-}
-
} // namespace mozc
diff --git a/src/mozc_version_template.txt b/src/mozc_version_template.txt
index 6fa2a73..12dadb7 100644
--- a/src/mozc_version_template.txt
+++ b/src/mozc_version_template.txt
@@ -1,6 +1,6 @@
MAJOR=2
MINOR=16
-BUILD=2030
+BUILD=2031
REVISION=102
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
# downloaded by NaCl Mozc.