1 //===-- StreamBroadcast.cpp -------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 #include "lldb/lldb-private.h"
13 #include "lldb/Core/Broadcaster.h"
14 #include "lldb/Core/Event.h"
15 #include "lldb/Core/StreamAsynchronousIO.h"
18 using namespace lldb_private;
21 StreamAsynchronousIO::StreamAsynchronousIO (Broadcaster &broadcaster, uint32_t broadcast_event_type) :
22 Stream (0, 4, eByteOrderBig),
23 m_broadcaster (broadcaster),
24 m_broadcast_event_type (broadcast_event_type),
29 StreamAsynchronousIO::~StreamAsynchronousIO ()
34 StreamAsynchronousIO::Flush ()
36 if (m_accumulated_data.GetSize() > 0)
38 std::unique_ptr<EventDataBytes> data_bytes_ap (new EventDataBytes);
39 // Let's swap the bytes to avoid LARGE string copies.
40 data_bytes_ap->SwapBytes (m_accumulated_data.GetString());
41 EventSP new_event_sp (new Event (m_broadcast_event_type, data_bytes_ap.release()));
42 m_broadcaster.BroadcastEvent (new_event_sp);
43 m_accumulated_data.Clear();
48 StreamAsynchronousIO::Write (const void *s, size_t length)
50 m_accumulated_data.Write (s, length);