LLDB mainline
|
BroadcasterImpl contains the actual Broadcaster implementation. More...
#include <Broadcaster.h>
Public Member Functions | |
BroadcasterImpl (Broadcaster &broadcaster) | |
~BroadcasterImpl ()=default | |
void | BroadcastEvent (lldb::EventSP &event_sp) |
void | BroadcastEventIfUnique (lldb::EventSP &event_sp) |
void | BroadcastEvent (uint32_t event_type) |
void | BroadcastEvent (uint32_t event_type, const lldb::EventDataSP &event_data_sp) |
void | BroadcastEventIfUnique (uint32_t event_type) |
void | Clear () |
uint32_t | AddListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask) |
const std::string & | GetBroadcasterName () const |
Broadcaster * | GetBroadcaster () |
bool | GetEventNames (Stream &s, const uint32_t event_mask, bool prefix_with_broadcaster_name) const |
void | SetEventName (uint32_t event_mask, const char *name) |
const char * | GetEventName (uint32_t event_mask) const |
bool | EventTypeHasListeners (uint32_t event_type) |
void | SetPrimaryListener (lldb::ListenerSP listener_sp) |
bool | RemoveListener (lldb_private::Listener *listener, uint32_t event_mask=UINT32_MAX) |
bool | RemoveListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX) |
bool | HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX) |
bool | IsHijackedForEvent (uint32_t event_mask) |
void | RestoreBroadcaster () |
Protected Types | |
typedef llvm::SmallVector< std::pair< lldb::ListenerWP, uint32_t >, 4 > | collection |
typedef std::map< uint32_t, std::string > | event_names_map |
Protected Member Functions | |
void | PrivateBroadcastEvent (lldb::EventSP &event_sp, bool unique) |
const char * | GetHijackingListenerName () |
llvm::SmallVector< std::pair< lldb::ListenerSP, uint32_t & >, 4 > | GetListeners (uint32_t event_mask=UINT32_MAX, bool include_primary=true) |
bool | HasListeners (uint32_t event_mask) |
Protected Attributes | |
Broadcaster & | m_broadcaster |
The broadcaster that this implements. | |
event_names_map | m_event_names |
Optionally define event names for readability and logging for each event bit. | |
collection | m_listeners |
A Broadcaster can have zero, one or many listeners. | |
std::mutex | m_listeners_mutex |
A mutex that protects m_listeners. | |
lldb::ListenerSP | m_primary_listener_sp |
See the discussion of Broadcasters and Listeners above. | |
uint32_t | m_primary_listener_mask = UINT32_MAX |
std::vector< lldb::ListenerSP > | m_hijacking_listeners |
A simple mechanism to intercept events from a broadcaster. | |
std::vector< uint32_t > | m_hijacking_masks |
At some point we may want to have a stack or Listener collections, but for now this is just for private hijacking. | |
Private Member Functions | |
BroadcasterImpl (const BroadcasterImpl &)=delete | |
const BroadcasterImpl & | operator= (const BroadcasterImpl &)=delete |
Friends | |
class | Listener |
class | Broadcaster |
BroadcasterImpl contains the actual Broadcaster implementation.
The Broadcaster makes a BroadcasterImpl which lives as long as it does. The Listeners & the Events hold a weak pointer to the BroadcasterImpl, so that they can survive if a Broadcaster they were listening to is destroyed w/o their being able to unregister from it (which can happen if the Broadcasters & Listeners are being destroyed on separate threads simultaneously. The Broadcaster itself can't be shared out as a weak pointer, because some things that are broadcasters (e.g. the Target and the Process) are shared in their own right.
For the most part, the Broadcaster functions dispatch to the BroadcasterImpl, and are documented in the public Broadcaster API above.
Definition at line 336 of file Broadcaster.h.
|
protected |
Definition at line 404 of file Broadcaster.h.
|
protected |
Definition at line 405 of file Broadcaster.h.
Broadcaster::BroadcasterImpl::BroadcasterImpl | ( | Broadcaster & | broadcaster | ) |
Definition at line 34 of file Broadcaster.cpp.
|
default |
|
privatedelete |
uint32_t Broadcaster::BroadcasterImpl::AddListener | ( | const lldb::ListenerSP & | listener_sp, |
uint32_t | event_mask | ||
) |
Definition at line 135 of file Broadcaster.cpp.
References UINT32_MAX.
void Broadcaster::BroadcasterImpl::BroadcastEvent | ( | lldb::EventSP & | event_sp | ) |
Definition at line 227 of file Broadcaster.cpp.
void Broadcaster::BroadcasterImpl::BroadcastEvent | ( | uint32_t | event_type | ) |
Definition at line 303 of file Broadcaster.cpp.
void Broadcaster::BroadcasterImpl::BroadcastEvent | ( | uint32_t | event_type, |
const lldb::EventDataSP & | event_data_sp | ||
) |
Definition at line 308 of file Broadcaster.cpp.
void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique | ( | lldb::EventSP & | event_sp | ) |
Definition at line 231 of file Broadcaster.cpp.
void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique | ( | uint32_t | event_type | ) |
Definition at line 314 of file Broadcaster.cpp.
void Broadcaster::BroadcasterImpl::Clear | ( | ) |
Definition at line 89 of file Broadcaster.cpp.
bool Broadcaster::BroadcasterImpl::EventTypeHasListeners | ( | uint32_t | event_type | ) |
Definition at line 173 of file Broadcaster.cpp.
Broadcaster * Broadcaster::BroadcasterImpl::GetBroadcaster | ( | ) |
Definition at line 101 of file Broadcaster.cpp.
|
inline |
Definition at line 361 of file Broadcaster.h.
References lldb_private::Broadcaster::GetBroadcasterName(), and m_broadcaster.
|
inline |
Definition at line 374 of file Broadcaster.h.
References m_event_names.
bool Broadcaster::BroadcasterImpl::GetEventNames | ( | Stream & | s, |
const uint32_t | event_mask, | ||
bool | prefix_with_broadcaster_name | ||
) | const |
Definition at line 105 of file Broadcaster.cpp.
References bit, lldb_private::Broadcaster::GetBroadcasterName(), lldb_private::Stream::PutChar(), and lldb_private::Stream::PutCString().
|
protected |
Definition at line 351 of file Broadcaster.cpp.
|
protected |
Definition at line 53 of file Broadcaster.cpp.
|
protected |
Definition at line 77 of file Broadcaster.cpp.
bool Broadcaster::BroadcasterImpl::HijackBroadcaster | ( | const lldb::ListenerSP & | listener_sp, |
uint32_t | event_mask = UINT32_MAX |
||
) |
Definition at line 328 of file Broadcaster.cpp.
References lldb_private::Events, lldb_private::Broadcaster::GetBroadcasterName(), lldb_private::GetLog(), and LLDB_LOG.
bool Broadcaster::BroadcasterImpl::IsHijackedForEvent | ( | uint32_t | event_mask | ) |
Definition at line 343 of file Broadcaster.cpp.
|
privatedelete |
|
protected |
Definition at line 235 of file Broadcaster.cpp.
References lldb_private::Events, lldb_private::Broadcaster::GetBroadcasterName(), lldb_private::StreamString::GetData(), lldb_private::GetLog(), and LLDB_LOG.
bool Broadcaster::BroadcasterImpl::RemoveListener | ( | const lldb::ListenerSP & | listener_sp, |
uint32_t | event_mask = UINT32_MAX |
||
) |
Definition at line 222 of file Broadcaster.cpp.
References lldb_private::Broadcaster::RemoveListener().
bool Broadcaster::BroadcasterImpl::RemoveListener | ( | lldb_private::Listener * | listener, |
uint32_t | event_mask = UINT32_MAX |
||
) |
Definition at line 186 of file Broadcaster.cpp.
void Broadcaster::BroadcasterImpl::RestoreBroadcaster | ( | ) |
Definition at line 358 of file Broadcaster.cpp.
References lldb_private::Events, lldb_private::Broadcaster::GetBroadcasterName(), lldb_private::GetLog(), and LLDB_LOG.
|
inline |
Definition at line 370 of file Broadcaster.h.
References m_event_names.
void Broadcaster::BroadcasterImpl::SetPrimaryListener | ( | lldb::ListenerSP | listener_sp | ) |
Definition at line 319 of file Broadcaster.cpp.
References lldb_private::Broadcaster::RemoveListener(), and UINT32_MAX.
|
friend |
Definition at line 338 of file Broadcaster.h.
|
friend |
Definition at line 337 of file Broadcaster.h.
|
protected |
The broadcaster that this implements.
Definition at line 413 of file Broadcaster.h.
Referenced by GetBroadcasterName().
|
protected |
Optionally define event names for readability and logging for each event bit.
Definition at line 417 of file Broadcaster.h.
Referenced by GetEventName(), and SetEventName().
|
protected |
A simple mechanism to intercept events from a broadcaster.
Definition at line 453 of file Broadcaster.h.
|
protected |
At some point we may want to have a stack or Listener collections, but for now this is just for private hijacking.
Definition at line 457 of file Broadcaster.h.
|
protected |
A Broadcaster can have zero, one or many listeners.
A Broadcaster with zero listeners is a no-op, with one Listener is trivial. In most cases of multiple Listeners,the Broadcaster treats all its Listeners as equal, sending each event to all of the Listeners in no guaranteed order. However, some Broadcasters - in particular the Process broadcaster, can designate one Listener to be the "Primary Listener". In the case of the Process Broadcaster, the Listener passed to the Process constructor will be the Primary Listener. If the broadcaster has a Primary Listener, then the event gets sent first to the Primary Listener, and then when the Primary Listener pulls the event and the the event's DoOnRemoval finishes running, the event is forwarded to all the other Listeners. The other wrinkle is that a Broadcaster may be serving a Hijack Listener. If the Hijack Listener is present, events are only sent to the Hijack Listener. We use that, for instance, to absorb all the events generated by running an expression so that they don't show up to the driver or UI as starts and stops. If a Broadcaster has both a Primary and a Hijack Listener, the top-most Hijack Listener is treated as the current Primary Listener. A list of Listener / event_mask pairs that are listening to this broadcaster.
Definition at line 442 of file Broadcaster.h.
|
protected |
A mutex that protects m_listeners.
Definition at line 445 of file Broadcaster.h.
|
protected |
Definition at line 450 of file Broadcaster.h.
|
protected |
See the discussion of Broadcasters and Listeners above.
Definition at line 448 of file Broadcaster.h.