- Online Community Forums » Allegro Development » al_lock_mutex() locks for both read and writes?

This thread is locked; no one can reply to it. rss feed Print
al_lock_mutex() locks for both read and writes?
Chris Katko
Member #1,881
January 2002

Shouldn't al_lock_mutex() allow locking separately for reading and writing?



“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Member #12,636
March 2011

Not quite, it wouldn't be a mutex then. A mutex is to exclude other threads from access to a certain block of code, no matter if the block reads or writes.
What do you need a readers writers lock for specifically?

Member #358
May 2000

No, it's just a normal mutex not a read-write lock. You can easily implement a read-write lock using a mutex though. I think a read/write lock would be useful enough to add to Allegro's API, if someone does want to add it. However if you use C++ just use for example std::shared_lock/std::unique_lock.

"Either help out or stop whining" - Evert

Go to: