Skip to content

Commit

Permalink
fix again
Browse files Browse the repository at this point in the history
  • Loading branch information
dsh0416 committed Dec 12, 2023
1 parent b334693 commit 6b2cf67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion lib/prolog_mqi/prolog_mqi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def query(value)
read
end

def query_async(value, find_all=true)
def query_async(value, find_all: true)
timeout_str = @timeout.nil? ? '_' : @timeout.to_s
find_all_str = find_all ? 'true' : 'false'
write("run_async(#{value}, #{timeout_str}, #{find_all_str})")
Expand All @@ -69,6 +69,13 @@ def query_async_result
read
end

def halt_server
write('halt')
read
end

private

def read
bytesize = @socket.gets.chomp(".\n").to_i
result = @socket.read(bytesize)
Expand All @@ -85,6 +92,8 @@ def write(value)
end

def stop
halt_server
ensure
@socket.close
@stdin.close
@stdout.close
Expand Down
2 changes: 1 addition & 1 deletion test/bench_prolog_mqi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def bench_revert_facts_instead_of_restart

puts "bench_revert_facts_instead_of_restart\t#{time_no_restart.real}\t#{time_restart.real}"

assert time_no_restart.real < time_restart.real
assert_operator time_no_restart.real, :<, time_restart.real
end
# rubocop:enable Metrics/AbcSize
end

0 comments on commit 6b2cf67

Please sign in to comment.