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

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

Issue 23498015: [NaCl SDK] Support non blocking TCP/UDP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 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_tcp.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.cc b/native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.cc
new file mode 100644
index 0000000000000000000000000000000000000000..24d7cdd4ee5821a50fc5a45de01ddef072ed6c78
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_tcp.cc
@@ -0,0 +1,53 @@
+// 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_tcp.h"
+
+#include <poll.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "nacl_io/fifo_char.h"
+#include "sdk_util/auto_lock.h"
+
+namespace nacl_io {
+
+EventEmitterTCP::EventEmitterTCP(size_t rsize, size_t wsize)
+ : in_fifo_(std::max<size_t>(65536, rsize)),
+ out_fifo_(std::max<size_t>(65536, wsize)) {
+ UpdateStatus_Locked();
+}
+
+uint32_t EventEmitterTCP::ReadIn_Locked(char* data, uint32_t len) {
+ uint32_t count = in_fifo_.Read(data, len);
+
+ UpdateStatus_Locked();
+ return count;
+}
+
+uint32_t EventEmitterTCP::WriteIn_Locked(const char* data, uint32_t len) {
+ uint32_t count = in_fifo_.Write(data, len);
+
+ UpdateStatus_Locked();
+ return count;
+}
+
+uint32_t EventEmitterTCP::ReadOut_Locked(char* data, uint32_t len) {
+ uint32_t count = out_fifo_.Read(data, len);
+
+ UpdateStatus_Locked();
+ return count;
+}
+
+uint32_t EventEmitterTCP::WriteOut_Locked(const char* data, uint32_t len) {
+ uint32_t count = out_fifo_.Write(data, len);
+
+ UpdateStatus_Locked();
+ return count;
+}
+
+
+} // namespace nacl_io
+
+

Powered by Google App Engine
This is Rietveld 408576698