- add sources.
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / libraries / nacl_io / event_emitter_pipe.cc
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <poll.h>
6 #include <stdint.h>
7 #include <stdlib.h>
8
9 #include "nacl_io/event_emitter_pipe.h"
10
11 namespace nacl_io {
12
13 EventEmitterPipe::EventEmitterPipe(size_t size)
14     : fifo_(std::max<size_t>(1, size)) {
15   UpdateStatus_Locked();
16 }
17
18 size_t EventEmitterPipe::Read_Locked(char* data, size_t len) {
19   size_t out_len = fifo_.Read(data, len);
20
21   UpdateStatus_Locked();
22   return out_len;
23 }
24
25 size_t EventEmitterPipe::Write_Locked(const char* data, size_t len) {
26   size_t out_len = fifo_.Write(data, len);
27
28   UpdateStatus_Locked();
29   return out_len;
30 }
31
32 }  // namespace nacl_io
33