LLDB mainline
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
lldb_private::Broadcaster::BroadcasterImpl Class Reference

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, EventData *event_data=nullptr)
 
void BroadcastEvent (uint32_t event_type, const lldb::EventDataSP &event_data_sp)
 
void BroadcastEventIfUnique (uint32_t event_type, EventData *event_data=nullptr)
 
void Clear ()
 
uint32_t AddListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask)
 
const char * GetBroadcasterName () const
 
BroadcasterGetBroadcaster ()
 
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)
 
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 ()
 

Protected Attributes

Broadcasterm_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 list of Listener / event_mask pairs that are listening to this broadcaster.
 
std::recursive_mutex m_listeners_mutex
 A mutex that protects m_listeners.
 
std::vector< lldb::ListenerSP > m_hijacking_listeners
 A simple mechanism to intercept events from a broadcaster.
 
std::vector< uint32_tm_hijacking_masks
 At some point we may want to have a stack or Listener collections, but for now this is just for private hijacking.
 
lldb::ListenerSP m_shadow_listener = nullptr
 A optional listener that all private events get also broadcasted to, on top the hijacked / default listeners.
 

Private Member Functions

 BroadcasterImpl (const BroadcasterImpl &)=delete
 
const BroadcasterImploperator= (const BroadcasterImpl &)=delete
 

Friends

class Listener
 
class Broadcaster
 

Detailed Description

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 329 of file Broadcaster.h.

Member Typedef Documentation

◆ collection

typedef llvm::SmallVector<std::pair<lldb::ListenerWP, uint32_t>, 4> lldb_private::Broadcaster::BroadcasterImpl::collection
protected

Definition at line 396 of file Broadcaster.h.

◆ event_names_map

Definition at line 397 of file Broadcaster.h.

Constructor & Destructor Documentation

◆ BroadcasterImpl() [1/2]

Broadcaster::BroadcasterImpl::BroadcasterImpl ( Broadcaster broadcaster)

Definition at line 34 of file Broadcaster.cpp.

◆ ~BroadcasterImpl()

lldb_private::Broadcaster::BroadcasterImpl::~BroadcasterImpl ( )
default

◆ BroadcasterImpl() [2/2]

lldb_private::Broadcaster::BroadcasterImpl::BroadcasterImpl ( const BroadcasterImpl )
privatedelete

Member Function Documentation

◆ AddListener()

uint32_t Broadcaster::BroadcasterImpl::AddListener ( const lldb::ListenerSP &  listener_sp,
uint32_t  event_mask 
)

Definition at line 114 of file Broadcaster.cpp.

◆ BroadcastEvent() [1/3]

void lldb_private::Broadcaster::BroadcasterImpl::BroadcastEvent ( lldb::EventSP &  event_sp)

◆ BroadcastEvent() [2/3]

void Broadcaster::BroadcasterImpl::BroadcastEvent ( uint32_t  event_type,
const lldb::EventDataSP &  event_data_sp 
)

Definition at line 254 of file Broadcaster.cpp.

◆ BroadcastEvent() [3/3]

void Broadcaster::BroadcasterImpl::BroadcastEvent ( uint32_t  event_type,
EventData event_data = nullptr 
)

Definition at line 248 of file Broadcaster.cpp.

◆ BroadcastEventIfUnique() [1/2]

void lldb_private::Broadcaster::BroadcasterImpl::BroadcastEventIfUnique ( lldb::EventSP &  event_sp)

◆ BroadcastEventIfUnique() [2/2]

void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique ( uint32_t  event_type,
EventData event_data = nullptr 
)

Definition at line 260 of file Broadcaster.cpp.

◆ Clear()

void Broadcaster::BroadcasterImpl::Clear ( )

Definition at line 69 of file Broadcaster.cpp.

◆ EventTypeHasListeners()

bool Broadcaster::BroadcasterImpl::EventTypeHasListeners ( uint32_t  event_type)

Definition at line 148 of file Broadcaster.cpp.

◆ GetBroadcaster()

Broadcaster * Broadcaster::BroadcasterImpl::GetBroadcaster ( )

Definition at line 80 of file Broadcaster.cpp.

◆ GetBroadcasterName()

const char * lldb_private::Broadcaster::BroadcasterImpl::GetBroadcasterName ( ) const
inline

◆ GetEventName()

const char * lldb_private::Broadcaster::BroadcasterImpl::GetEventName ( uint32_t  event_mask) const
inline

Definition at line 368 of file Broadcaster.h.

References m_event_names.

◆ GetEventNames()

bool Broadcaster::BroadcasterImpl::GetEventNames ( Stream s,
const uint32_t  event_mask,
bool  prefix_with_broadcaster_name 
) const

◆ GetHijackingListenerName()

const char * Broadcaster::BroadcasterImpl::GetHijackingListenerName ( )
protected

Definition at line 289 of file Broadcaster.cpp.

◆ GetListeners()

llvm::SmallVector< std::pair< ListenerSP, uint32_t & >, 4 > Broadcaster::BroadcasterImpl::GetListeners ( )
protected

Definition at line 53 of file Broadcaster.cpp.

◆ HijackBroadcaster()

bool Broadcaster::BroadcasterImpl::HijackBroadcaster ( const lldb::ListenerSP &  listener_sp,
uint32_t  event_mask = UINT32_MAX 
)

◆ IsHijackedForEvent()

bool Broadcaster::BroadcasterImpl::IsHijackedForEvent ( uint32_t  event_mask)

Definition at line 281 of file Broadcaster.cpp.

◆ operator=()

const BroadcasterImpl & lldb_private::Broadcaster::BroadcasterImpl::operator= ( const BroadcasterImpl )
privatedelete

◆ PrivateBroadcastEvent()

void Broadcaster::BroadcasterImpl::PrivateBroadcastEvent ( lldb::EventSP &  event_sp,
bool  unique 
)
protected

◆ RemoveListener() [1/2]

bool Broadcaster::BroadcasterImpl::RemoveListener ( const lldb::ListenerSP &  listener_sp,
uint32_t  event_mask = UINT32_MAX 
)

Definition at line 176 of file Broadcaster.cpp.

References lldb_private::Broadcaster::RemoveListener().

◆ RemoveListener() [2/2]

bool Broadcaster::BroadcasterImpl::RemoveListener ( lldb_private::Listener listener,
uint32_t  event_mask = UINT32_MAX 
)

Definition at line 161 of file Broadcaster.cpp.

◆ RestoreBroadcaster()

void Broadcaster::BroadcasterImpl::RestoreBroadcaster ( )

◆ SetEventName()

void lldb_private::Broadcaster::BroadcasterImpl::SetEventName ( uint32_t  event_mask,
const char *  name 
)
inline

Definition at line 364 of file Broadcaster.h.

References m_event_names.

Friends And Related Function Documentation

◆ Broadcaster

friend class Broadcaster
friend

Definition at line 331 of file Broadcaster.h.

◆ Listener

friend class Listener
friend

Definition at line 330 of file Broadcaster.h.

Member Data Documentation

◆ m_broadcaster

Broadcaster& lldb_private::Broadcaster::BroadcasterImpl::m_broadcaster
protected

The broadcaster that this implements.

Definition at line 403 of file Broadcaster.h.

Referenced by GetBroadcasterName().

◆ m_event_names

event_names_map lldb_private::Broadcaster::BroadcasterImpl::m_event_names
protected

Optionally define event names for readability and logging for each event bit.

Definition at line 407 of file Broadcaster.h.

Referenced by GetEventName(), and SetEventName().

◆ m_hijacking_listeners

std::vector<lldb::ListenerSP> lldb_private::Broadcaster::BroadcasterImpl::m_hijacking_listeners
protected

A simple mechanism to intercept events from a broadcaster.

Definition at line 417 of file Broadcaster.h.

◆ m_hijacking_masks

std::vector<uint32_t> lldb_private::Broadcaster::BroadcasterImpl::m_hijacking_masks
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 421 of file Broadcaster.h.

◆ m_listeners

collection lldb_private::Broadcaster::BroadcasterImpl::m_listeners
protected

A list of Listener / event_mask pairs that are listening to this broadcaster.

Definition at line 411 of file Broadcaster.h.

◆ m_listeners_mutex

std::recursive_mutex lldb_private::Broadcaster::BroadcasterImpl::m_listeners_mutex
protected

A mutex that protects m_listeners.

Definition at line 414 of file Broadcaster.h.

◆ m_shadow_listener

lldb::ListenerSP lldb_private::Broadcaster::BroadcasterImpl::m_shadow_listener = nullptr
protected

A optional listener that all private events get also broadcasted to, on top the hijacked / default listeners.

Definition at line 425 of file Broadcaster.h.


The documentation for this class was generated from the following files: