diff --git a/data/core/init.lua b/data/core/init.lua index f8ea2818..6710ab8a 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -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 diff --git a/scripts/dmon-test.sh b/scripts/dmon-test.sh new file mode 100644 index 00000000..7103a955 --- /dev/null +++ b/scripts/dmon-test.sh @@ -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"