DEBUG: Add debug support for dmon

This commit is contained in:
Francesco Abbate 2021-07-23 23:14:45 +02:00
parent 7098043e6e
commit 52636b4acc
2 changed files with 32 additions and 1 deletions

View File

@ -1042,16 +1042,19 @@ function core.dir_rescan_add_job(dir, filepath)
for _, key_path in ipairs(remove_list) do
scheduled_rescan[key_path] = nil
end
print("DEBUG: adding rescan thread for", abs_dirpath)
scheduled_rescan[abs_dirpath] = {dir = dir, path = dirpath_rooted, abs_path = abs_dirpath, time_limit = new_time}
core.add_thread(function()
while true do
local rescan = scheduled_rescan[abs_dirpath]
if not rescan then return end
if not rescan then print("DEBUG: cancel rescan for", abs_dirpath); return end
if system.get_time() > rescan.time_limit then
local has_changes = rescan_project_subdir(rescan.dir, rescan.path)
print("DEBUG: rescan done for", abs_dirpath, " changes", has_changes)
if has_changes then
rescan.time_limit = new_time
else
print("DEBUG: terminating rescan for", abs_dirpath)
scheduled_rescan[rescan.abs_path] = nil
return
end
@ -1214,6 +1217,7 @@ end)
function core.run()
local idle_iterations = 0
local debug_count = 0
while true do
core.frame_start = system.get_time()
local did_redraw = core.step()
@ -1231,6 +1235,8 @@ function core.run()
local dt = math.ceil(t / h) * h - t
system.wait_event(dt + 1 / config.fps)
else
print("DEBUG:", debug_count, " application WAITING")
debug_count = debug_count + 1
system.wait_event()
end
end

25
scripts/dmon-test.sh Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
IFS=$'\r\n' GLOBIGNORE='*' command eval 'DIRS=($(find . -type d))'
n=${#DIRS[@]}
files=()
for i in {1..20}; do
files[$i]="${DIRS[$(( $RANDOM % $n ))]}/dmon-test-$i.txt"
done
for name in "${files[@]}"; do
echo "create ${name#./}"
touch "${name#./}"
done
echo "Files created"
sleep 2;
for name in "${files[@]}"; do
echo "remove ${name#./}"
rm "${name#./}"
done
echo "Files removed"