| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkMessageBus_DEFINED | 8 #ifndef SkMessageBus_DEFINED |
| 9 #define SkMessageBus_DEFINED | 9 #define SkMessageBus_DEFINED |
| 10 | 10 |
| 11 #include "SkLazyPtr.h" | 11 #include "SkLazyPtr.h" |
| 12 #include "SkMutex.h" | |
| 13 #include "SkTArray.h" | 12 #include "SkTArray.h" |
| 14 #include "SkTDArray.h" | 13 #include "SkTDArray.h" |
| 14 #include "SkThread.h" |
| 15 #include "SkTypes.h" | 15 #include "SkTypes.h" |
| 16 | 16 |
| 17 template <typename Message> | 17 template <typename Message> |
| 18 class SkMessageBus : SkNoncopyable { | 18 class SkMessageBus : SkNoncopyable { |
| 19 public: | 19 public: |
| 20 // Post a message to be received by all Inboxes for this Message type. Thre
adsafe. | 20 // Post a message to be received by all Inboxes for this Message type. Thre
adsafe. |
| 21 static void Post(const Message& m); | 21 static void Post(const Message& m); |
| 22 | 22 |
| 23 class Inbox { | 23 class Inbox { |
| 24 public: | 24 public: |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 template <typename Message> | 102 template <typename Message> |
| 103 /*static*/ void SkMessageBus<Message>::Post(const Message& m) { | 103 /*static*/ void SkMessageBus<Message>::Post(const Message& m) { |
| 104 SkMessageBus<Message>* bus = SkMessageBus<Message>::Get(); | 104 SkMessageBus<Message>* bus = SkMessageBus<Message>::Get(); |
| 105 SkAutoMutexAcquire lock(bus->fInboxesMutex); | 105 SkAutoMutexAcquire lock(bus->fInboxesMutex); |
| 106 for (int i = 0; i < bus->fInboxes.count(); i++) { | 106 for (int i = 0; i < bus->fInboxes.count(); i++) { |
| 107 bus->fInboxes[i]->receive(m); | 107 bus->fInboxes[i]->receive(m); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 #endif // SkMessageBus_DEFINED | 111 #endif // SkMessageBus_DEFINED |
| OLD | NEW |