Flutter Engine
The Flutter Engine
Public Member Functions | Friends | List of all members
SkMessageBus< Message, IDType, AllowCopyableMessage >::Inbox Class Reference

#include <SkMessageBus.h>

Public Member Functions

 Inbox (IDType uniqueID)
 
 ~Inbox ()
 
IDType uniqueID () const
 
void poll (skia_private::TArray< Message > *out)
 

Friends

class SkMessageBus
 

Detailed Description

template<typename Message, typename IDType, bool AllowCopyableMessage = true>
class SkMessageBus< Message, IDType, AllowCopyableMessage >::Inbox

Definition at line 45 of file SkMessageBus.h.

Constructor & Destructor Documentation

◆ Inbox()

template<typename Message , typename IDType , bool AllowCopyableMessage>
SkMessageBus< Message, IDType, AllowCopyableMessage >::Inbox::Inbox ( IDType  uniqueID)

Definition at line 87 of file SkMessageBus.h.

88 : fUniqueID(uniqueID) {
89 // Register ourselves with the corresponding message bus.
91 SkAutoMutexExclusive lock(bus->fInboxesMutex);
92 bus->fInboxes.push_back(this);
93}
IDType uniqueID() const
Definition: SkMessageBus.h:50

◆ ~Inbox()

template<typename Message , typename IDType , bool AllowCopyableMessage>
SkMessageBus< Message, IDType, AllowCopyableMessage >::Inbox::~Inbox

Definition at line 96 of file SkMessageBus.h.

96 {
97 // Remove ourselves from the corresponding message bus.
99 SkAutoMutexExclusive lock(bus->fInboxesMutex);
100 // This is a cheaper fInboxes.remove(fInboxes.find(this)) when order doesn't matter.
101 for (int i = 0; i < bus->fInboxes.size(); i++) {
102 if (this == bus->fInboxes[i]) {
103 bus->fInboxes.removeShuffle(i);
104 break;
105 }
106 }
107}

Member Function Documentation

◆ poll()

template<typename Message , typename IDType , bool AllowCopyableMessage>
void SkMessageBus< Message, IDType, AllowCopyableMessage >::Inbox::poll ( skia_private::TArray< Message > *  out)

Definition at line 116 of file SkMessageBus.h.

117 {
118 SkASSERT(messages);
119 messages->clear();
120 SkAutoMutexExclusive lock(fMessagesMutex);
121 fMessages.swap(*messages);
122}
#define SkASSERT(cond)
Definition: SkAssert.h:116
void swap(TArray &that)
Definition: SkTArray.h:358

◆ uniqueID()

template<typename Message , typename IDType , bool AllowCopyableMessage = true>
IDType SkMessageBus< Message, IDType, AllowCopyableMessage >::Inbox::uniqueID ( ) const
inline

Definition at line 50 of file SkMessageBus.h.

50{ return fUniqueID; }

Friends And Related Function Documentation

◆ SkMessageBus

template<typename Message , typename IDType , bool AllowCopyableMessage = true>
friend class SkMessageBus
friend

Definition at line 60 of file SkMessageBus.h.


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