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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/event_emitter_stream.cc

Issue 23498015: [NaCl SDK] Support non blocking TCP/UDP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added Fifo Tests 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698