Skip to content

Commit

Permalink
nb_setval(self_space,MSpace)
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSPoon committed Aug 30, 2024
1 parent ec6f6c1 commit 5555908
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
15 changes: 8 additions & 7 deletions src/canary/metta_space.pl
Original file line number Diff line number Diff line change
Expand Up @@ -668,22 +668,23 @@
*/
search_for1(X):-
forall((metta_atom(_Where,What),contains_var(X,What)),
write_src_nl(What)).
(nl,write_src_nl(What))).

search_for2(X):-
forall((metta_src(_Where,What),contains_var(X,What)),
write_src_woi_nl(What)).
forall((metta_file_src(_Where,What),contains_var(X,What)),
(nl,write_src_nl(What))).


metta_src(Where,What):-
metta_file_src(Where,What):-
loaded_into_kb(Where,File), metta_file_buffer(_,What,Vars,File,_Loc),
ignore(maplist(name_the_var,Vars)).


name_the_var(N=V):- ignore((atom_concat('_',NV,N),V='$VAR'(NV))).
guess_metta_vars(What):-
ignore(once((metta_file_buffer(_,What0,Vars,_File,_Loc),
alpha_unif(What,What0),
alpha_unify(What,What0),
maplist(name_the_var,Vars)))).
name_the_var(N=V):- ignore((atom_concat('_',NV,N),V='$VAR'(NV))).

alpha_unify(What,What0):- What=@=What0,(nonvar(What)->What=What0;What==What0).

alpha_unif(What,What0):- What=@=What0,What=What0.
10 changes: 7 additions & 3 deletions src/canary_docme/metta_server.pl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
:- use_module(library(thread)). % Provides predicates for multi-threading

% Predicate to execute a goal and determine if it was deterministic
%! call_wdet(+Goal, -WasDet) is semidet.
%! call_wdet(+Goal, -WasDet) is nondet.
%
% Calls the given Goal and checks if it was deterministic.
%
Expand Down Expand Up @@ -125,12 +125,14 @@
% Start the VSpace service with the generated Alias, MSpace, and Port
start_vspace_service(Alias,MSpace,Port).

% Skip starting the service if it is already running
%! start_vspace_service(+Alias, +_Space, +_Port) is det.
%! start_vspace_service(+Alias, +Space, +Port) is det.
%
% Starts the VSpace service only if it is not already running under the given Alias.
%
% @arg Alias is the alias to check for an existing service.


% Skip starting the service if it is already running
start_vspace_service(Alias,_Space,_Port):-
% If the service is already running under Alias, do nothing
service_running(Alias),
Expand Down Expand Up @@ -219,6 +221,8 @@
setup_call_cleanup(
% Open the socket as a stream
tcp_open_socket(RemoteFd, Stream),
% Generate a unique symbol for the thread alias
nb_setval(self_space,MSpace),
% Handle the connection by processing incoming goals
ignore(handle_vspace_peer(Stream)),
% Ensure the stream is closed when done
Expand Down

0 comments on commit 5555908

Please sign in to comment.