Pipes allow exchanging messages. Messages are Prolog terms and are copied. An unbounded queue can be created by the predicate pipe_new/1. A bounded queue can be created by the predicate pipe_new/2. Pipes need not be explicitly destroyed, they will automatically be reclaimed by the Java GC when not anymore used. Threads waiting for a pipe can be interrupted.
Example:?- pipe_new(1, Q), pipe_put(Q, p(X)), pipe_take(Q, R). Q = 0ra2a372, R = p(_A)
The predicates pipe_put/2, pipe_offer/2 and pipe_offer_timeout/3
allow sending a message to a bounded queue. The predicates will
block, fail or timeout when the bounded queue is full. The
predicate pipe_put/2 can also be used for unbounded queues and
will never block. The predicates pipe_take/3, pipe_poll/2 and
pipe_poll_timeout/3 allow getting a message from a pipe. The
predicates will block, fail or timeout when the pipe is empty.