Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: experimental/conways_life/threading/condition_lock.h

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/conways_life/stamp.cc ('k') | experimental/conways_life/threading/pthread_ext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/conways_life/threading/condition_lock.h
diff --git a/experimental/conways_life/threading/condition_lock.h b/experimental/conways_life/threading/condition_lock.h
deleted file mode 100644
index e2d4cd5dc16bcce45b4235dfd30e7f66514a49cd..0000000000000000000000000000000000000000
--- a/experimental/conways_life/threading/condition_lock.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright (c) 2011 The Native Client Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONDITION_LOCK_H_
-#define CONDITION_LOCK_H_
-
-#include <pthread.h>
-
-namespace threading {
-// Class to manage a lock associated with a specific value. The calling thread
-// can ask to acquire the lock only when the lock is in a certain condition.
-class ConditionLock {
- public:
- ConditionLock() : condition_value_(0) {
- InitLock();
- }
- explicit ConditionLock(int32_t condition_value)
- : condition_value_(condition_value) {
- InitLock();
- }
-
- virtual ~ConditionLock() {
- pthread_cond_destroy(&condition_condition_);
- pthread_mutex_destroy(&condition_lock_);
- }
-
- // Acquire the mutex without regard to the condition.
- void Lock() {
- pthread_mutex_lock(&condition_lock_);
- }
-
- // Acquire the mutex lock when the lock values are equal. Blocks the
- // calling thread until the lock can be acquired and the condition is met.
- void LockWhenCondition(int32_t condition_value) {
- Lock();
- while (condition_value != condition_value_) {
- pthread_cond_wait(&condition_condition_, &condition_lock_);
- }
- // When this method returns, |contition_lock_| will be acquired. The
- // calling thread must unlock it.
- }
-
- // Acquire the mutex lock when the lock values are _NOT_ equal. Blocks the
- // calling thread until the lock can be acquired and the condition is met.
- void LockWhenNotCondition(int32_t condition_value) {
- Lock();
- while (condition_value == condition_value_) {
- pthread_cond_wait(&condition_condition_, &condition_lock_);
- }
- // When this method returns, |contition_lock_| will be acquired. The
- // calling thread must unlock it.
- }
-
- // Release the lock without changing the condition. Signal the condition
- // so that threads waiting in LockWhenCondtion() will wake up. If there are
- // no threads waiting for the signal, this has the same effect as a simple
- // mutex unlock.
- void Unlock() {
- pthread_cond_broadcast(&condition_condition_);
- pthread_mutex_unlock(&condition_lock_);
- }
-
- // Release the lock, setting the condition's value. This assumes that
- // |condition_lock_| has been acquired.
- void UnlockWithCondition(unsigned int condition_value) {
- condition_value_ = condition_value;
- Unlock();
- }
-
- // Return the current condition value without any mutex protection.
- int32_t condition_value() const {
- return condition_value_;
- }
-
- private:
- void InitLock() {
- pthread_mutex_init(&condition_lock_, NULL);
- pthread_cond_init(&condition_condition_, NULL);
- }
-
- pthread_mutex_t condition_lock_;
- pthread_cond_t condition_condition_;
- int32_t condition_value_;
-};
-} // namespace threading
-
-#endif // CONDITION_LOCK_H_
« no previous file with comments | « experimental/conways_life/stamp.cc ('k') | experimental/conways_life/threading/pthread_ext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698