Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common: Add a Subscribable class (from #5758) #6264

Closed
wants to merge 2 commits into from

Conversation

leoetlino
Copy link
Member

@leoetlino leoetlino commented Dec 20, 2017

From PR #5758 (rebased on top of master)

Adds a Subscribable class in Common, to encapsulate the callback management logic. Could probably be used in other places with callbacks, too. Calling Subscribable().Subscribe returns a move-only value that, when destructed, unsubscribes the callback if the original Subscribable still exists (thread-safe).

This is not used anywhere yet, but I plan to replace the existing callbacks with Subscribables (Core::SetOnStoppedCallback, config change callbacks).

@@ -0,0 +1,20 @@
// Copyright 2017 Dolphin Emulator Project

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@leoetlino leoetlino mentioned this pull request Dec 25, 2017
Subscribable* subscribable = nullptr;
};

void Unsubscribe(SubscriptionID id) { m_callbacks.erase(id); }

This comment was marked as off-topic.

This comment was marked as off-topic.

@degasus
Copy link
Member

degasus commented Jan 5, 2018

The common helper LGTM.

@leoetlino
Copy link
Member Author

I'll re-submit this if/when I actually end up using this utility.

@leoetlino leoetlino closed this May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants