Home Help Center

RWRecLock - Again

acbellacbell Member Andrew BellOrganization: Iowa State UniversityProject: National Resources Inventory ✭✭
Hi,

There was another thread about this topic, but I would appreciate it if someone could confirm that this was a feature and not a bug.

This works:

IceUtil::RWRecMutex::WLock sync(*this);
IceUtil::RWRecMutex::WLock sync(*this);
cerr << "Success.\n";

This doesn't work:

IceUtil::RWRecMutex::WLock sync(*this);
IceUtil::RWRecMutex::RLock sync(*this);
cerr << "Success.\n";

Even though the read lock is "more permissive" than the write lock.

Thanks,

Comments

  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    It is not a bug. Please see this thread:

    http://www.zeroc.com/vbulletin/showthread.php?t=1268
  • acbellacbell Member Andrew BellOrganization: Iowa State UniversityProject: National Resources Inventory ✭✭
    Thanks

    OK,

    Thanks for confirmation on this behavior. I had a little trouble interpreting the response in the referenced thread.

    It would be nice to have some sort of a read lock that DID work inside a write lock:

    obtain write lock
    if (test_function())
    set some value.
    release write lock

    test_function()
    {
    obtain read lock
    return some status info.
    release read lock
    }

    Without this, it makes it kind of a pain to have test functions that can be used in the context of a test/set and outside that context. With the current scheme, you need to put a write lock in your test function, which is more restrictive than necessary.

    Cheers,
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    You can always write a wrapper class for RWRecMutex that implements this behavior. For the RWRecMutex in Ice, we want to stick to Posix semantics, and introduce as little overhead as possible.

    As an aside, can you please update your signature with the project you are working on? Please see this thread for details.
Sign In or Register to comment.