Practice meeting, Oct. 7th

Skip to first unread message

Lyle Kopnicky

Sep 24, 2019, 10:29:02 PM9/24/19
to pdxfunc
When: Monday, Oct 7th, 6:30-8:30pm

Where: Collective Agency Downtown, Suite 1108, 511 SW 10th Ave, Portland, OR (opposite side of the floor from the elevators)

We'll discuss Chapter 12, "Concurrent Network Servers", of Parallel and Concurrent Programming in Haskell. Please read it beforehand. You may wish to try running the code examples from the book. At the meeting anyone will be able to present and contribute to the discussion.

Meetup link to RSVP:

Hope to see you then!

Lyle Kopnicky

Oct 8, 2019, 12:47:45 AM10/8/19
to pdxfunc
Tonight we further studied the number-multiplying server example in Chapter 12. First we attempted to answer some of the questions the book posed, such as what happens when Ctrl+C is pressed on the client side, or the server side? This led us to experimenting with adding some debugging code to show what exceptions were being thrown and how they were propagated. We also talked about how to use readMay from the Safe library to check whether a string would decode into a number, rather than throwing an exception. And we looked at how we could open a log file using withFile, that would automatically be closed in case of an exception.

Then we studied the more advanced server2, in which a command could be sent to change the multiplier. Marlow discussed 4 different designs. The first one had much too much contention for a shared variable. The second design had less contention, but still had some when the multiplier was changed. The third design was efficient, if a bit complex, due to requiring three server threads and two channels per client. The fourth and final design used STM and only needed two server threads and one channel per client. We walked through the operation of each.

I pointed out that there was a subtle difference between designs 3 and 4: the fourth design, using STM, might not notice every time the multiplication factor changed. However, it could still guarantee that if it started multiplying numbers at a new factor, that it had previously notified its client of the new factor.

Next time we'll continue with the chat server example, to finish Chapter 12.

- Lyle
Reply all
Reply to author
0 new messages