-
Notifications
You must be signed in to change notification settings - Fork 163
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
Update BindingCallbackThreadObserver to be one per sync client #6156
Changes from 27 commits
9297774
7c95e91
f60cc60
019fe2a
1b69942
bfdcceb
c6e7b59
3261f7f
2bbd6e4
d649105
5ac0e3e
80e09e9
24b2d08
6c648c8
868f0f9
147b6f2
a8ea573
f890ed1
b9a1cf0
555e12d
0a9812a
4567abd
6d2f826
a2c1241
d8cb9d0
b73d863
b972b54
047a9b6
4f39bd2
0e92873
552a97c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,51 @@ | |
#include <realm/sync/binding_callback_thread_observer.hpp> | ||
|
||
namespace realm { | ||
BindingCallbackThreadObserver* g_binding_callback_thread_observer = nullptr; | ||
|
||
void BindingCallbackThreadObserver::call_did_create_thread( | ||
const std::shared_ptr<BindingCallbackThreadObserver>& observer_ptr) | ||
{ | ||
// Call into the observer ptr if not null, otherwise, use the global thread observer | ||
if (observer_ptr) | ||
observer_ptr->did_create_thread(); | ||
} | ||
|
||
void BindingCallbackThreadObserver::call_will_destroy_thread( | ||
const std::shared_ptr<BindingCallbackThreadObserver>& observer_ptr) | ||
{ | ||
// Call into the observer ptr if not null, otherwise, use the global thread observer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like there is no global observer? Do we still need these static functions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were just helper functions... I'll remove them and just use the direct function calls in the default socket provider. |
||
if (observer_ptr) | ||
observer_ptr->will_destroy_thread(); | ||
} | ||
|
||
bool BindingCallbackThreadObserver::call_handle_error( | ||
const std::exception& e, const std::shared_ptr<BindingCallbackThreadObserver>& observer_ptr) | ||
{ | ||
// Call into the observer ptr if not null, otherwise, use the global thread observer | ||
if (observer_ptr) | ||
return observer_ptr->handle_error(e); | ||
return false; | ||
} | ||
|
||
void BindingCallbackThreadObserver::did_create_thread() | ||
{ | ||
if (m_create_thread_callback) { | ||
(*m_create_thread_callback)(); | ||
} | ||
} | ||
|
||
void BindingCallbackThreadObserver::will_destroy_thread() | ||
{ | ||
if (m_destroy_thread_callback) { | ||
(*m_destroy_thread_callback)(); | ||
} | ||
} | ||
|
||
bool BindingCallbackThreadObserver::handle_error(const std::exception& e) | ||
{ | ||
if (!m_handle_error_callback) | ||
return false; | ||
|
||
return (*m_handle_error_callback)(e); | ||
} | ||
} // namespace realm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are both functions needed? Isn't this one enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One sets the global thread observer (the way it works now) and the other sets the thread observer in
SyncClientConfig
to specify one on a "per app" basis (the new way).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to keep using it the way it works now (with the global thread observer)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep both for now, and, if the Java/Kotlin SDK team decides to move one way or the other, we can remove the other method. I'm not sure if/when they will be ready to migrate to the app-specific usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we decided to just have the per-app version...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the (only) function for setting the thread observer in the SyncClientConfig. If you prefer, I can move this function declaration so it is with the other
realm_sync_client_config_...
functions