-
June 18th, 2014, 12:21 PM
#16
Re: Book recommendation for win32 multi-thread programming
You'd be pretty 'stupid' not to make sure your synchronisation/locking is properly wrapped in a class so you can indeed use RAII.
Nothing worse than getting an exception and having a lock remain pending indefinately.
-
June 18th, 2014, 03:43 PM
#17
Re: Book recommendation for win32 multi-thread programming
Originally Posted by OReubens
You'd be pretty 'stupid' not to make sure your synchronisation/locking is properly wrapped in a class so you can indeed use RAII.
You would think, yet many folks code with explicit unlocking.
-
June 20th, 2014, 05:14 AM
#18
Re: Book recommendation for win32 multi-thread programming
Hmm but that's a slightly different issue isn't it ?
Just because you wrap your lock in a wrapper, doesn't mean it's always/necessarily a good idea to unlock ONLY when the lock-object goes out of scope (or to introduce 'dummy' {} blocks only to make the object go out of scope at a specific point in the code sequence.
I never understood RAII as meaning "only clean up when the object is destroyed", but rather "make sure cleanup will always happen, if it's already cleaned up, that's fine too".
-
June 20th, 2014, 07:30 PM
#19
Re: Book recommendation for win32 multi-thread programming
I find it's helpful to encapsulate the locking inside side classes whenever possible so that users of the class are unaware of the synchronization. I find that when classes expose the lock objects and callers are expected to do the locking, it can lead to problems. Of course you can't always structure the code this way, but I certainly try.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|