Book recommendation for win32 multi-thread programming - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19

Thread: Book recommendation for win32 multi-thread programming

  1. #16
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,827

    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.

  2. #17
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,220

    Re: Book recommendation for win32 multi-thread programming

    Quote Originally Posted by OReubens View Post
    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.

  3. #18
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,827

    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".

  4. #19
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,220

    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.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center