Discussions related to Visual Prolog
Martin Meyer
VIP Member
Posts: 369
Joined: 14 Nov 2002 0:01

Mutex

Post by Martin Meyer »

Hello Thomas,

please check this; it might be a mistake otherwise please explain: Running the code

Code: Select all

class facts     myMutex : mutex := mutex::create(false).   clauses     run() :-         %stdIO::write(toBoolean(myMutex:isSet())),         myMutex:release().
throws an exception because a mutex that has not been entered cannot be released. However, if the commented-out line is enabled, no exception occurs and “true” is output.

Apparently, isSet/0 changes the state of the mutex. Yet the name suggests that the predicate is merely intended to query the state.
Regards Martin