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

Unified Diff: media/blink/waiter_index.cc

Issue 1165903002: Multi reader/writer cache/buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more tests Created 5 years, 2 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
« media/blink/waiter_index.h ('K') | « media/blink/waiter_index.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/waiter_index.cc
diff --git a/media/blink/waiter_index.cc b/media/blink/waiter_index.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fb3899643190e88cd0acb8313d99bba352a1c991
--- /dev/null
+++ b/media/blink/waiter_index.cc
@@ -0,0 +1,38 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/blink/waiter_index.h"
+
+namespace media {
+
+WaiterIndex::WaiterIndex() {}
+WaiterIndex::~WaiterIndex() {}
+
+void WaiterIndex::WaitFor(int32_t pos, Waiter* waiter) {
+ waiters_[pos].insert(waiter);
+}
+
+void WaiterIndex::StopWaitFor(int32_t pos, Waiter* waiter) {
+ std::map<int32_t, std::set<Waiter*> >::iterator i = waiters_.find(pos);
+ if (i != waiters_.end()) {
+ i->second.erase(waiter);
+ if (i->second.empty()) {
+ waiters_.erase(i);
+ }
+ }
+}
+
+void WaiterIndex::WakeUp(int32_t pos) {
+ std::map<int32_t, std::set<Waiter*> >::iterator i = waiters_.find(pos);
+ if (i != waiters_.end()) {
+ std::set<Waiter*> tmp;
+ tmp.swap(i->second);
+ waiters_.erase(pos);
+ for (Waiter* waiter: tmp) {
+ waiter->Continue();
+ }
+ }
+}
+
+} // namespace media
« media/blink/waiter_index.h ('K') | « media/blink/waiter_index.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698