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.
4
5#include "nacl_io/socket/udp_event_emitter.h"
6
7#include "sdk_util/auto_lock.h"
8
9namespace nacl_io {
10
11UdpEventEmitter::UdpEventEmitter(size_t rsize, size_t wsize)
12    : in_fifo_(rsize), out_fifo_(wsize) {
13  UpdateStatus_Locked();
14}
15
16Packet* UdpEventEmitter::ReadRXPacket_Locked() {
17  Packet* packet = in_fifo_.ReadPacket();
18
19  UpdateStatus_Locked();
20  return packet;
21}
22
23void UdpEventEmitter::WriteRXPacket_Locked(Packet* packet) {
24  in_fifo_.WritePacket(packet);
25
26  UpdateStatus_Locked();
27}
28
29Packet* UdpEventEmitter::ReadTXPacket_Locked() {
30  Packet* packet = out_fifo_.ReadPacket();
31
32  UpdateStatus_Locked();
33  return packet;
34}
35
36void UdpEventEmitter::WriteTXPacket_Locked(Packet* packet) {
37  out_fifo_.WritePacket(packet);
38
39  UpdateStatus_Locked();
40}
41
42}  // namespace nacl_io
43