You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2015/06/14 11:46:34 UTC
[16/21] mesos git commit: Update ZooKeeper tests to use synchronized.
Update ZooKeeper tests to use synchronized.
Review: https://reviews.apache.org/r/35101
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f4aaa143
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f4aaa143
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f4aaa143
Branch: refs/heads/master
Commit: f4aaa14392298ca5cbde260560ee32e73f9f2328
Parents: 5a69aa7
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Sat Jun 13 07:20:47 2015 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Sun Jun 14 02:43:01 2015 -0700
----------------------------------------------------------------------
src/hook/manager.cpp | 6 ------
src/tests/zookeeper.cpp | 25 +++++++++++++------------
src/tests/zookeeper.hpp | 1 -
3 files changed, 13 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/f4aaa143/src/hook/manager.cpp
----------------------------------------------------------------------
diff --git a/src/hook/manager.cpp b/src/hook/manager.cpp
index 5236035..b43b918 100644
--- a/src/hook/manager.cpp
+++ b/src/hook/manager.cpp
@@ -121,8 +121,6 @@ Labels HookManager::masterLaunchTaskLabelDecorator(
return taskInfo_.labels();
}
-
- UNREACHABLE();
}
@@ -150,8 +148,6 @@ Labels HookManager::slaveRunTaskLabelDecorator(
return taskInfo_.labels();
}
-
- UNREACHABLE();
}
@@ -176,8 +172,6 @@ Environment HookManager::slaveExecutorEnvironmentDecorator(
return executorInfo.command().environment();
}
-
- UNREACHABLE();
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/f4aaa143/src/tests/zookeeper.cpp
----------------------------------------------------------------------
diff --git a/src/tests/zookeeper.cpp b/src/tests/zookeeper.cpp
index 08cab86..5012017 100644
--- a/src/tests/zookeeper.cpp
+++ b/src/tests/zookeeper.cpp
@@ -33,8 +33,7 @@
#include <stout/lambda.hpp>
#include <stout/path.hpp>
#include <stout/os.hpp>
-
-#include "common/lock.hpp"
+#include <stout/synchronized.hpp>
#include "logging/logging.hpp"
@@ -121,9 +120,10 @@ void ZooKeeperTest::TestWatcher::process(
int64_t sessionId,
const string& path)
{
- Lock lock(&mutex);
- events.push(Event(type, state, path));
- pthread_cond_signal(&cond);
+ synchronized (mutex) {
+ events.push(Event(type, state, path));
+ pthread_cond_signal(&cond);
+ }
}
@@ -158,14 +158,15 @@ void ZooKeeperTest::TestWatcher::awaitCreated(const string& path)
ZooKeeperTest::TestWatcher::Event
ZooKeeperTest::TestWatcher::awaitEvent()
{
- Lock lock(&mutex);
- while (true) {
- while (events.empty()) {
- pthread_cond_wait(&cond, &mutex);
+ synchronized (mutex) {
+ while (true) {
+ while (events.empty()) {
+ pthread_cond_wait(&cond, &mutex);
+ }
+ Event event = events.front();
+ events.pop();
+ return event;
}
- Event event = events.front();
- events.pop();
- return event;
}
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/f4aaa143/src/tests/zookeeper.hpp
----------------------------------------------------------------------
diff --git a/src/tests/zookeeper.hpp b/src/tests/zookeeper.hpp
index d8f1cb3..32fc83b 100644
--- a/src/tests/zookeeper.hpp
+++ b/src/tests/zookeeper.hpp
@@ -19,7 +19,6 @@
#ifndef __TESTS_ZOOKEEPER_HPP__
#define __TESTS_ZOOKEEPER_HPP__
-#include <pthread.h>
#include <stdint.h>
#include <gtest/gtest.h>