annotate framework/env/execute/_create_sorted_execution_list.lua @ 480:e09654c4a042
Allow main handlers to use a poll function that indicates when process termination is requested
author |
jbe |
date |
Tue Jun 06 16:14:33 2017 +0200 (2017-06-06) |
parents |
d7814e6d0124 |
children |
|
rev |
line source |
jbe@206
|
1 function execute._create_sorted_execution_list(add_paths, execute_func)
|
jbe@206
|
2 local entries = {}
|
jbe@206
|
3 add_paths(function(...)
|
jbe@206
|
4 local full_path = encode.file_path(WEBMCP_BASE_PATH, "app", ...)
|
jbe@206
|
5 local relative_path = encode.file_path("", ...)
|
jbe@206
|
6 local filenames = extos.listdir(full_path)
|
jbe@206
|
7 if filenames then
|
jbe@206
|
8 table.sort(filenames) -- not really neccessary, due to sorting afterwards
|
jbe@206
|
9 for i, filename in ipairs(filenames) do
|
jbe@206
|
10 if string.find(filename, "%.lua$") then
|
jbe@206
|
11 if entries[filename] then
|
jbe@450
|
12 error('More than one filter or initializer is named "' .. filename .. '".')
|
jbe@206
|
13 end
|
jbe@206
|
14 entries[#entries+1] = filename
|
jbe@206
|
15 entries[filename] = function()
|
jbe@206
|
16 execute_func(
|
jbe@206
|
17 encode.file_path(full_path, filename),
|
jbe@206
|
18 encode.file_path(relative_path, filename)
|
jbe@206
|
19 )
|
jbe@206
|
20 end
|
jbe/bsw@0
|
21 end
|
jbe/bsw@0
|
22 end
|
jbe/bsw@0
|
23 end
|
jbe@206
|
24 end)
|
jbe@206
|
25 table.sort(entries)
|
jbe@206
|
26 for idx, filename in ipairs(entries) do
|
jbe@226
|
27 entries[idx] = entries[filename]
|
jbe@206
|
28 entries[filename] = nil
|
jbe/bsw@0
|
29 end
|
jbe@206
|
30 return entries
|
jbe/bsw@0
|
31 end
|