Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Mar 20, 2024
1 parent 8598b54 commit ba24b7b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
39 changes: 39 additions & 0 deletions samples/test_threads8.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
:- initialization(main).
:- dynamic f/2.

loops(1000).

main :-
format("Starting~n", []),
thread_create(thread_run(1), _, [alias(bar1)]),
thread_create(thread_run(2), _, [alias(bar2)]),
thread_create(thread_run(3), _, [alias(bar3)]),
thread_create(thread_run(4), _, [alias(bar4)]),
fail.
main :-
loops(LOOPS),
between(1, LOOPS, I),
%format(" ...Sending ~w~n", [I]),
assertz(foo(1,I)),
assertz(foo(2,I)),
assertz(foo(3,I)),
assertz(foo(4,I)),
fail.
main :-
thread_join(bar1, _),
thread_join(bar2, _),
thread_join(bar3, _),
thread_join(bar4, _),
true.

thread_run(J) :-
sleep(0.1),
format(" ...Thread ~w~n", [J]),
loops(LOOPS),
between(1,LOOPS,I),
retract(foo(J, I)),
format(" ...Got ~w ~w~n", [I, foo(J)]),
fail.
thread_run(J) :-
format("Terminating ~w~n", [J]),
true.
4 changes: 2 additions & 2 deletions src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ static void leave_predicate(query *q, predicate *pr)
}
#elif 0
if (pr->idx && pr->cnt) {
sl_remove(pr->idx2, r);
sl_remove(pr->idx, r);
sl_remove(pr->idx2, r); // buggy
sl_remove(pr->idx, r); // buggy
}
#endif

Expand Down

0 comments on commit ba24b7b

Please sign in to comment.