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

Unified Diff: native_client_sdk/src/libraries/nacl_io/fifo_char.h

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/fifo_char.h
diff --git a/native_client_sdk/src/libraries/nacl_io/fifo_char.h b/native_client_sdk/src/libraries/nacl_io/fifo_char.h
new file mode 100644
index 0000000000000000000000000000000000000000..e38034aef6e5f622765d37399880efb155d45f5f
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/fifo_char.h
@@ -0,0 +1,54 @@
+// 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.
+
+#ifndef LIBRARIES_NACL_IO_FIFO_CHAR_H_
+#define LIBRARIES_NACL_IO_FIFO_CHAR_H_
+
+#include <vector>
+
+#include "nacl_io/fifo_interface.h"
+
+#include "sdk_util/macros.h"
+
+namespace nacl_io {
+
+// FIFOChar
+//
+// A FIFOChar is a circular buffer, signalling FULL and EMPTY as appropriate.
+class FIFOChar : public FIFOInterface {
+ public:
+ explicit FIFOChar(size_t size);
+ virtual ~FIFOChar();
+
+ virtual bool IsEmpty();
+ virtual bool IsFull();
+ virtual bool Resize(size_t len);
+
+ size_t ReadAvailable();
+ size_t WriteAvailable();
+
+ // Reads out no more than the requested len without updating the tail.
+ // Returns actual amount read.
+ size_t Peek(void* buf, size_t len);
+
+ // Reads out the data making room in the FIFO. Returns actual amount
+ // read.
+ size_t Read(void* buf, size_t len);
+
+ // Writes into the FIFO no more than len bytes, returns actual amount
+ // written.
+ size_t Write(const void* buf, size_t len);
+
+private:
+ char* buffer_;
+ size_t size_; // Size of the FIFO
+ size_t avail_; // How much data is currently available
+ size_t tail_; // Next read location
+
+ DISALLOW_COPY_AND_ASSIGN(FIFOChar);
+};
+
+} // namespace nacl_io
+
+#endif // LIBRARIES_NACL_IO_FIFO_CHAR_H_
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/event_listener.cc ('k') | native_client_sdk/src/libraries/nacl_io/fifo_char.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698