diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /gfx/angle/src/libANGLE/signal_utils.h | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'gfx/angle/src/libANGLE/signal_utils.h')
-rwxr-xr-x | gfx/angle/src/libANGLE/signal_utils.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/gfx/angle/src/libANGLE/signal_utils.h b/gfx/angle/src/libANGLE/signal_utils.h new file mode 100755 index 000000000..835f2c602 --- /dev/null +++ b/gfx/angle/src/libANGLE/signal_utils.h @@ -0,0 +1,74 @@ +// +// Copyright 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// signal_utils: +// Helper classes for tracking dependent state changes between objects. +// These changes are signaled to the dependent class via channels. + +#ifndef LIBANGLE_SIGNAL_UTILS_H_ +#define LIBANGLE_SIGNAL_UTILS_H_ + +#include <set> + +#include "common/angleutils.h" + +namespace angle +{ + +// Message token passed to the receiver; +using SignalToken = uint32_t; + +// Interface that the depending class inherits from. +class SignalReceiver +{ + public: + virtual ~SignalReceiver() = default; + virtual void signal(SignalToken token) = 0; +}; + +class ChannelBinding; + +// The host class owns the channel. It uses the channel to fire signals to the receiver. +class BroadcastChannel final : NonCopyable +{ + public: + BroadcastChannel(); + ~BroadcastChannel(); + + void signal() const; + void reset(); + + private: + // Only the ChannelBinding class should add or remove receivers. + friend class ChannelBinding; + void addReceiver(ChannelBinding *receiver); + void removeReceiver(ChannelBinding *receiver); + + std::vector<ChannelBinding *> mReceivers; +}; + +// The dependent class keeps bindings to the host's BroadcastChannel. +class ChannelBinding final +{ + public: + ChannelBinding(SignalReceiver *receiver, SignalToken token); + ~ChannelBinding(); + ChannelBinding(const ChannelBinding &other) = default; + ChannelBinding &operator=(const ChannelBinding &other) = default; + + void bind(BroadcastChannel *channel); + void reset(); + void signal() const; + void onChannelClosed(); + + private: + BroadcastChannel *mChannel; + SignalReceiver *mReceiver; + SignalToken mToken; +}; + +} // namespace angle + +#endif // LIBANGLE_SIGNAL_UTILS_H_ |