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
th/no-gasyncresult #227
th/no-gasyncresult #227
Conversation
there are quite some FIXME comments. I may address them still in this branch... |
95c4dd0
to
b53c35f
Compare
b53c35f
to
e1c15d5
Compare
f1ca166
to
ff33c79
Compare
…Result pattern All operations must be cancellable in a timely manner, otherwise, the objects hang during shutdown. Also, get rid of the GAsyncResult pattern. It is more cumbersome than helpful. There are still several issues, marked by FIXME comments.
We should not use GAsyncResult. At least, not for internal API. It's more cumbersome then helpful, in my opinion. It requires this awkward async_finish() pattern. Instead, let the caller pass a suitable callback of the right type.
ff33c79
to
935f808
Compare
Previously nm_ppp_manager_stop() would return a handle which makes it easy to cancel the operation. However, sometimes, we may want to cancel an operation based on an GCancellable. So, extend nm_ppp_manager_stop() to hook it with a cancellable. Essentially, move the code from nm-modem.c to nm-ppp-manager-call.c, where it belongs and where the functionality gets available to every component.
935f808
to
4273430
Compare
- fix stopping ppp-manager. Previously, we would take a reference to priv->ppp_manager to cancel it later. However, deactivate_cleanup() is called first, which already issues nm_ppp_manager_stop(). Thereby, not using a callback and not waiting for the operation to complete. - get rid of this "step" state machine. There are litterally two steps that need to be performed asynchornously. Instead chain the calls. - it is now obviously visible, that the async callback never completes synchronously upon being called (provided that all async operations that it calls themself have this behavior -- which they should).
4273430
to
e61ead5
Compare
LGTM |
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.
It's more cumbersome then helpful, in my opinion. It requires this awkward async_finish() pattern.
Well; whether it's awkward ot not is purely a matter of taste.
Good thing that you get rid of a handful of GSimpleAsyncResults though. Those are not portable to more recent GLib versions.
merged |
I think the
GAsyncResult
pattern is less than optimal.Maybe it serves a purpose in public glib API, where it better works for language bindings/introspection. For NetworkManager core, it's just a nuisance.
It results in
GAsyncReadyCallback
. Also,g_simple_async_result_set_op_res_gpointer()
etc. looses type information).GAsyncResult
is itself aGObject
, ref-counted and unnecessary "features". In most cases, we need a simple heap allocation to package the user-data and relevant state.nm_utils_user_data_pack()
is enough).