aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2025-09-14 21:46:33 +0200
committerJan Sucan <jan@jansucan.com>2025-09-14 21:46:33 +0200
commitf01b5a8122bd5135ee984ba2c1c25fc3c833c5f6 (patch)
treea71b37752597585235445dc37eb8b13f02289c06
parent9d89965b0661d1968151d9b646148b6a71209705 (diff)
23_a_3: Add solution
-rw-r--r--README.md2
-rw-r--r--ch23/23_a_3.hs17
2 files changed, 18 insertions, 1 deletions
diff --git a/README.md b/README.md
index 2253d19..33fe9eb 100644
--- a/README.md
+++ b/README.md
@@ -186,7 +186,7 @@ are prefixed with 'Module_'.
| 19_b_3 | yes, in 19_b_2 | | |
| **_23_a_1_** | yes | 529 | 23. GUI programming with gtk2hs|
| 23_a_2 | yes, in 23_a_1 | | |
-| 23_a_3 | | | |
+| 23_a_3 | yes | | |
| **_24_a_1_** | | 542 | 24. Concurrent and multicore programming |
| 24_a_2 | | | |
| **_24_b_1_** | | 551 | |
diff --git a/ch23/23_a_3.hs b/ch23/23_a_3.hs
new file mode 100644
index 0000000..c8e808b
--- /dev/null
+++ b/ch23/23_a_3.hs
@@ -0,0 +1,17 @@
+-- Why does guiFetch combine worker functions instead of calling statusWindow
+-- twice?
+
+
+-- The most important reason is: Considering how the operations are implemented,
+-- updating the podcast and downloading its episodes need to be run sequentially
+-- in that order because the downloading can produce expected results only when
+-- it knows the latest information about the podcast's episodes.
+--
+-- Calling statusWindow twice would run those operations concurrently and their
+-- execution ordering could not be predicted. For example, the downloading could
+-- be run before the updating.
+--
+-- Other than that, the statusWindow uses the same GUI status window. The latter
+-- call to it would overwrite information from the former call, replacing the
+-- callback for canceling the child thread. Then it wouldn't be possible for the
+-- user to cancel the first thread.