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

Unified Diff: native_client_sdk/src/libraries/nacl_io/event_emitter_stream.cc

Issue 23498015: [NaCl SDK] Support non blocking TCP/UDP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added Fifo Tests Created 7 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
Index: native_client_sdk/src/libraries/nacl_io/event_emitter_stream.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_stream.cc b/native_client_sdk/src/libraries/nacl_io/event_emitter_stream.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3297b83895d9936e056efff6b3c4ab8feaad5257
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_stream.cc
@@ -0,0 +1,45 @@
+// Copyright (c) 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 "nacl_io/event_emitter_stream.h"
+
+#include <poll.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "nacl_io/fifo_interface.h"
+#include "sdk_util/auto_lock.h"
+
+namespace nacl_io {
+
+EventEmitterStream::EventEmitterStream() : EventEmitter(), stream_(NULL) {}
binji 2013/09/15 22:18:58 nit: not necessary to specify EventEmitter() here.
noelallen1 2013/09/17 21:21:54 Done.
+
+void EventEmitterStream::AttachStream(MountNodeStream* stream) {
+ AUTO_LOCK(GetLock());
+ stream_ = stream;
+}
+
+void EventEmitterStream::DetachStream() {
+ AUTO_LOCK(GetLock());
+
+ RaiseEvents_Locked(POLLHUP);
+ stream_ = NULL;
+}
+
+void EventEmitterStream::UpdateStatus_Locked() {
+ uint32_t status = 0;
+ if (!rx_fifo()->IsEmpty())
+ status |= POLLIN;
+
+ if (!tx_fifo()->IsFull())
+ status |= POLLOUT;
+
+ ClearEvents_Locked(~status);
+ RaiseEvents_Locked(status);
+}
+
+
+} // namespace nacl_io
+
+

Powered by Google App Engine
This is Rietveld 408576698