Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Mar 18, 2024
1 parent 0b5ad11 commit ac58786
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions samples/test_threads7.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
:- initialization(main).

loops(1000).

main :-
message_queue_create(_, [alias(foo)]),
format("Starting~n", []),
thread_create(thread_run(1), _, [alias(bar)]),
thread_create(thread_run(2), _, [alias(baz)]),
delay(1),
fail.
main :-
loops(LOOPS),
between(1, LOOPS, I),
%format(" ...Sending ~w~n", [I]),
thread_send_message(foo, foo(1)),
thread_send_message(foo, foo(2)),
fail.
main :-
thread_join(bar, _),
thread_join(baz, _),
true.

thread_run(J) :-
format(" ...Thread ~w~n", [J]),
loops(LOOPS),
between(1,LOOPS,I),
thread_get_message(foo, foo(J)),
%format(" ...Got ~w ~w~n", [I, foo(J)]),
fail.
thread_run(J) :-
format("Terminating ~w~n", [J]),
true.

0 comments on commit ac58786

Please sign in to comment.