Results 1 to 2 of 2

Thread: Suggest hiding mutex::lock and unlock

  1. #1

    Default Suggest hiding mutex::lock and unlock

    Hi,

    I suggest making mutex lock and unlock private rather then public as they are now.

    The only reason is avoid potential nasty cases where in:

    mutex.lock();
    do_something();
    mutex.unlock();

    do_something throws exception. This will leave mutex locked, and then heavens help you debugging these cases...

    One can do the same thing using MutexSection:

    CL_MutexSection section( mutex );
    do_something_with_lock();
    section.unlock();
    do_something_without_lock();

    but in this case any exceptions will release the lock properly.

    I am sure Mutex and Section were meant to be used this way. But hiding Mutex modifiers will simply enforce this good design without any drawbacks that I can see.

    While we're at it, changing documentation to show only the good usage would be advisable. I will gladly do it, but I am getting my feet wet only, have not generated docs once yet...

    Miki.
    Attached Files Attached Files

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    [snip]
    However, I could be totally wrong!
    ...
    i was totally wrong!
    Last edited by rombust; 10-02-2008 at 11:02 AM. Reason: silly me

Similar Threads

  1. Bought yesterday, got no unlock code
    By blahblah in forum Dungeon Scroll for PC and iPhone
    Replies: 2
    Last Post: 06-23-2007, 01:49 PM
  2. Dungeon Scroll unlock thru firewall problem
    By in forum Dungeon Scroll for PC and iPhone
    Replies: 2
    Last Post: 04-13-2004, 11:08 PM

Bookmarks

Bookmarks

Posting Permissions

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