/* Simple test for tabling. A table is created sequentially, then after the table is completed, threads read from the table concurrentl N times. This tests concurrent reads as well as concurrent tabletry. Threads are sharing a table, but this shouldn't matter for now. */ :- import for/3 from basics. :- thread_shared num_is/1. :- dynamic num_is/1. :- assert((concurr_initialize(tableread(N,_)):- retractall(num_is(_)), assert(num_is(N)), (tableread_table(_),fail;true))). :- thread_shared tableread_table/1. :- table tableread_table/1. tableread_table(X):- num_is(N), for(X,1,N). tableread(N,_Str):- for(_X,1,N), tableread_table(_), fail. tableread(_,Str):- tableread_table(X), writeln(Str,X), fail. tableread(_,_).