After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 745092 - programming-guidelines: Add a page on asynchronous programming
programming-guidelines: Add a page on asynchronous programming
Status: RESOLVED OBSOLETE
Product: gnome-devel-docs
Classification: Applications
Component: programming-guidelines
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME Devel docs: Programming Guidelines maintainer(s)
gnome-devel-docs maintainers
Depends on:
Blocks:
 
 
Reported: 2015-02-24 15:21 UTC by Philip Withnall
Modified: 2019-02-11 10:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
programming-guidelines: Add a page on asynchronous programming (43.29 KB, patch)
2015-02-24 15:21 UTC, Philip Withnall
none Details | Review
programming-guidelines: Add a page on asynchronous programming (43.84 KB, patch)
2015-10-21 07:52 UTC, Philip Withnall
none Details | Review

Description Philip Withnall 2015-02-24 15:21:10 UTC
Fairly self contained, but links in well with the existing main-contexts and threading pages.
Comment 1 Philip Withnall 2015-02-24 15:21:18 UTC
Created attachment 297772 [details] [review]
programming-guidelines: Add a page on asynchronous programming

This covers various techniques for using and defining GAsyncResult-style
asynchronous methods, based around the use of examples.
Comment 2 David King 2015-02-24 15:42:58 UTC
Review of attachment 297772 [details] [review]:

Skimmed over the code, but you need a review from Ryan.

::: programming-guidelines/C/async-programming.page
@@ +97,3 @@
+      <item>
+        <code mime="text/x-csrc">
+foo_file_load_data_async (FooFile             *self,

Is it worth mentioning the odd API examples (discussed on the mailing list) where the sync variants are foo_sync(), and the async variants are foo()? (probably not)

@@ +177,3 @@
+
+    <p>
+      Which approach is used depends on the class’ design. A class which wraps

Would be nice to use a preposition (rather than the genitive) here (and throughout). "…depends on the design of the class."
Comment 3 Philip Withnall 2015-02-24 16:03:52 UTC
(In reply to David King from comment #2)
> Review of attachment 297772 [details] [review] [review]:
> 
> Skimmed over the code, but you need a review from Ryan.
> 
> ::: programming-guidelines/C/async-programming.page
> @@ +97,3 @@
> +      <item>
> +        <code mime="text/x-csrc">
> +foo_file_load_data_async (FooFile             *self,
> 
> Is it worth mentioning the odd API examples (discussed on the mailing list)
> where the sync variants are foo_sync(), and the async variants are foo()?
> (probably not)

I think it probably is worth mentioning briefly.

> @@ +177,3 @@
> +
> +    <p>
> +      Which approach is used depends on the class’ design. A class which
> wraps
> 
> Would be nice to use a preposition (rather than the genitive) here (and
> throughout). "…depends on the design of the class."

Yes, that would be a nice improvement.

I’ll make those changes once review #2 is done by Ryan.
Comment 4 Philip Withnall 2015-10-06 07:33:08 UTC
Ryan, would you be able to find some time to look at this please?
Comment 5 Matthias Clasen 2015-10-07 03:08:35 UTC
Review of attachment 297772 [details] [review]:

::: programming-guidelines/C/main-contexts.page
@@ +464,3 @@
     <p>
+      Always <link xref="async-programming">write things asynchronously</link>
+      internally (using

I have some serious reservations about this style of blanket advice. Writing everything async typically leads to a giant rats nest of callbacks that are really hard to maintain, compared to a nice and clean worker thread. You should inform people about the pros and cons of the various tools at their disposal, and then let them choose the best tool for the job.
Comment 6 Philip Withnall 2015-10-21 07:52:11 UTC
Created attachment 313791 [details] [review]
programming-guidelines: Add a page on asynchronous programming

This covers various techniques for using and defining GAsyncResult-style
asynchronous methods, based around the use of examples.

---

Tweaked that paragraph to mention threading, but discourage it.

The programming guidelines are aimed at novice-to-intermediate coders who are getting used to GLib/GNOME, as I understand it. Advanced coders who know the tradeoffs are very welcome to use threads when they are the most appropriate tool. Anyone who is not an advanced coder is pretty much bound to get threading wrong though, so it's not something I particularly want to encourage.

And people don't just get threading wrong: they get it wrong but are convinced they've got it right, because nobody understands race conditions properly.
Comment 7 Philip Withnall 2016-11-21 12:07:39 UTC
Ping?
Comment 8 Philip Withnall 2018-01-18 11:05:23 UTC
Ping? :-)
Comment 9 Philip Withnall 2019-02-11 10:45:05 UTC
Turned into an MR at https://gitlab.gnome.org/GNOME/gnome-devel-docs/merge_requests/13.