Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 "nacl_io/event_emitter_stream.h" | |
| 6 | |
| 7 #include <poll.h> | |
| 8 #include <stdint.h> | |
| 9 #include <stdlib.h> | |
| 10 | |
| 11 #include "nacl_io/fifo_interface.h" | |
| 12 #include "sdk_util/auto_lock.h" | |
| 13 | |
| 14 namespace nacl_io { | |
| 15 | |
| 16 EventEmitterStream::EventEmitterStream() : EventEmitter(), stream_(NULL) {} | |
|
binji
2013/09/15 22:18:58
nit: not necessary to specify EventEmitter() here.
noelallen1
2013/09/17 21:21:54
Done.
| |
| 17 | |
| 18 void EventEmitterStream::AttachStream(MountNodeStream* stream) { | |
| 19 AUTO_LOCK(GetLock()); | |
| 20 stream_ = stream; | |
| 21 } | |
| 22 | |
| 23 void EventEmitterStream::DetachStream() { | |
| 24 AUTO_LOCK(GetLock()); | |
| 25 | |
| 26 RaiseEvents_Locked(POLLHUP); | |
| 27 stream_ = NULL; | |
| 28 } | |
| 29 | |
| 30 void EventEmitterStream::UpdateStatus_Locked() { | |
| 31 uint32_t status = 0; | |
| 32 if (!rx_fifo()->IsEmpty()) | |
| 33 status |= POLLIN; | |
| 34 | |
| 35 if (!tx_fifo()->IsFull()) | |
| 36 status |= POLLOUT; | |
| 37 | |
| 38 ClearEvents_Locked(~status); | |
| 39 RaiseEvents_Locked(status); | |
| 40 } | |
| 41 | |
| 42 | |
| 43 } // namespace nacl_io | |
| 44 | |
| 45 | |
| OLD | NEW |