1 // Copyright 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.
5 #include "nacl_io/pipe/pipe_node.h"
12 #include "nacl_io/ioctl.h"
13 #include "nacl_io/kernel_handle.h"
14 #include "nacl_io/pipe/pipe_event_emitter.h"
17 const size_t kDefaultPipeSize
= 512 * 1024;
22 PipeNode::PipeNode(Filesystem
* fs
)
23 : StreamNode(fs
), pipe_(new PipeEventEmitter(kDefaultPipeSize
)) {
26 PipeEventEmitter
* PipeNode::GetEventEmitter() {
30 Error
PipeNode::Read(const HandleAttr
& attr
,
34 int ms
= attr
.IsBlocking() ? read_timeout_
: 0;
36 EventListenerLock
wait(GetEventEmitter());
37 Error err
= wait
.WaitOnEvent(POLLIN
, ms
);
43 return GetEventEmitter()->Read_Locked(static_cast<char*>(buf
), count
,
47 Error
PipeNode::Write(const HandleAttr
& attr
,
51 int ms
= attr
.IsBlocking() ? write_timeout_
: 0;
53 EventListenerLock
wait(GetEventEmitter());
54 Error err
= wait
.WaitOnEvent(POLLOUT
, ms
);
60 return GetEventEmitter()->Write_Locked(static_cast<const char*>(buf
),
64 } // namespace nacl_io