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

Unified Diff: native_client_sdk/src/libraries/nacl_io/event_emitter_udp.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_udp.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter_udp.cc b/native_client_sdk/src/libraries/nacl_io/event_emitter_udp.cc
new file mode 100644
index 0000000000000000000000000000000000000000..af9f160f65c1145028207c8f8c54543e4e1aa044
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter_udp.cc
@@ -0,0 +1,49 @@
+// 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_udp.h"
+
+#include <poll.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "sdk_util/auto_lock.h"
+
+namespace nacl_io {
+
+EventEmitterUDP::EventEmitterUDP(size_t rsize, size_t wsize)
+ : in_fifo_(std::max<size_t>(1, rsize)),
+ out_fifo_(std::max<size_t>(1, wsize)) {
+ UpdateStatus_Locked();
+}
+
+Packet* EventEmitterUDP::ReadRXPacket_Locked() {
+ Packet* packet = in_fifo_.ReadPacket();
+
+ UpdateStatus_Locked();
+ return packet;
+}
+
+void EventEmitterUDP::WriteRXPacket_Locked(Packet* packet) {
+ in_fifo_.WritePacket(packet);
+
+ UpdateStatus_Locked();
+}
+
+Packet* EventEmitterUDP::ReadTXPacket_Locked() {
+ Packet* packet = out_fifo_.ReadPacket();
+
+ UpdateStatus_Locked();
+ return packet;
+}
+
+void EventEmitterUDP::WriteTXPacket_Locked(Packet* packet) {
+ out_fifo_.WritePacket(packet);
+
+ UpdateStatus_Locked();
+}
+
+} // namespace nacl_io
+
+
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/event_emitter_udp.h ('k') | native_client_sdk/src/libraries/nacl_io/event_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698