:- include('lib').
trick(a(gnu), b(software)).
trick(_, c(is)).
% Master
init:-
pm2_is_master,!,
pl_thread_send_msg(vid(3,0,_,_), a(gnu)),
pl_thread_send_msg(vid(2,0,_,_), b(software)),
pl_thread_send_msg(vid(1,0,_,_), c(is)),
read_results,
finish_listeners. % never remove this unless you know what
% you're doing
% Workers
init:-
mutex_lock,
pl_thread_get_msg(Termo),
!, trick(Termo, X),
write('Worker -> '),write(Termo), write(','), write(X), nl,
pl_thread_send_msg(vid(0,0,_,_), X).
read_results:-
pl_thread_get_msg(Result1),
write('Master -> '),write(Result1),nl,
read_results.
And the output:
$ pm2load tabard
Worker -> b(software),c(is)
Master -> c(is)
Worker -> a(gnu),b(software)
Master -> b(software)
Master -> c(is)
Worker -> c(is),c(is)