Linked by Thom Holwerda on Fri 7th Sep 2007 19:38 UTC, submitted by koki
BeOS & Derivatives Haiku developer Stephan Assmus (Stippi) has posted the first in a series of articles on the topics of multithreaded applications. Stephan writes: "Though I am programming on BeOS since 1999, only in recent years I have slowly become more comfortable with various multithreading related issues in my programs. So I thought I'd like to share some of my experiences here for beginning programmers or programmers skeptical about multithreading. I hope to be extending this as a series of articles to help learn the benefits and pitfalls of multithreading. All with an emphasis on programming for Haiku's API."
Permalink for comment 269749
To read all comments associated with this story, please click here.
RE[2]: Great but...
by anevilyak on Sat 8th Sep 2007 06:13 UTC in reply to "RE: Great but..."
anevilyak
Member since:
2005-09-14


While his solution solves the problem, it introduces more complexity into the code and perhaps more importantly it adds yet another lock (lock for each message queue which he doesn't show in the article but would be required). He also doesn't follow his own advice of "hold a lock for as short of a time as possible". Invalidate() doesn't require holding the data lock so he shouldn't call it while holding the lock.


The message queues share the window lock in BeOS. Those are implicitly there as Lock A and B in his example, and are taken care of for you by the API in this case.

Edited 2007-09-08 06:14 UTC

Reply Parent Bookmark Score: 2