Flutter Engine
The Flutter Engine
Classes | Static Public Member Functions | List of all members
SkMessageBus< Message, IDType, AllowCopyableMessage > Class Template Reference

#include <SkMessageBus.h>

Inheritance diagram for SkMessageBus< Message, IDType, AllowCopyableMessage >:
SkNoncopyable

Classes

class  Inbox
 
struct  is_sk_sp
 
struct  is_sk_sp< sk_sp< T > >
 

Static Public Member Functions

static void Post (Message m)
 

Detailed Description

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

The following method must have a specialization for type 'Message':

bool SkShouldPostMessageToBus(const Message&, IDType msgBusUniqueID)

We may want to consider providing a default template implementation, to avoid this requirement by sending to all inboxes when the specialization for type 'Message' is not present.

Definition at line 30 of file SkMessageBus.h.

Member Function Documentation

◆ Post()

template<typename Message , typename IDType , bool AllowCopyableMessage>
void SkMessageBus< Message, IDType, AllowCopyableMessage >::Post ( Message  m)
static

Definition at line 130 of file SkMessageBus.h.

130 {
132 SkAutoMutexExclusive lock(bus->fInboxesMutex);
133 for (int i = 0; i < bus->fInboxes.size(); i++) {
134 if (SkShouldPostMessageToBus(m, bus->fInboxes[i]->fUniqueID)) {
135 if constexpr (AllowCopyableMessage) {
136 bus->fInboxes[i]->receive(m);
137 } else {
138 if constexpr (is_sk_sp<Message>::value) {
139 SkASSERT(m->unique());
140 }
141 bus->fInboxes[i]->receive(std::move(m));
142 break;
143 }
144 }
145 }
146
147 if constexpr (is_sk_sp<Message>::value && !AllowCopyableMessage) {
148 // Make sure sk_sp has been sent to an inbox.
149 SkASSERT(!m); // NOLINT(bugprone-use-after-move)
150 }
151}
bool SkShouldPostMessageToBus(const GrClientMappedBufferManager::BufferFinishedMessage &, GrDirectContext::DirectContextID potentialRecipient)
#define SkASSERT(cond)
Definition: SkAssert.h:116
uint8_t value

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