The blocking database operators
introduced above can be implemented with wait-for.
For example, predicate ``querysync f(a, b)''
can be defined by the following.
Operator deletesync can be defined similarly.
However, when a fact say ``f(a, b)'' is added into the database,
an event ``add-f(a, b)'' must be posted either by the user
or by the runtime system.
The accept operator can also be elegantly defined in terms
of wait-for as follows, where g is the name of a gate.
Predicate wait-for also provides a possible means to implement
locking and unlocking of database relations, as follows.
Once an ``unlocked(Object)'' event is posted, only one thread
waiting for it is woken up nondeterministically to consider its
wait-for predicate.
So this definition guarantees that the lock not be grabbed by
several threads at the same time.
Since those predicates can be specified, we do not really have to implement them.