-
-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,000 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,8 @@ | |
"/libs/", | ||
"/3rd", | ||
"/.vscode", | ||
"/meta" | ||
"/meta", | ||
"script/ltask/lualib" | ||
], | ||
"checkThirdParty": false | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
local boot = require "ltask.bootstrap" | ||
|
||
local SERVICE_ROOT <const> = 1 | ||
local MESSSAGE_SYSTEM <const> = 0 | ||
|
||
local function bootstrap_root(initfunc, config) | ||
local sid = assert(boot.new_service("root", config.service_source, config.service_chunkname, SERVICE_ROOT)) | ||
assert(sid == SERVICE_ROOT) | ||
boot.init_root(SERVICE_ROOT) | ||
-- send init message to root service | ||
local init_msg, sz = boot.pack("init", { | ||
initfunc = initfunc, | ||
name = "root", | ||
args = {config} | ||
}) | ||
-- self bootstrap | ||
boot.post_message { | ||
from = SERVICE_ROOT, | ||
to = SERVICE_ROOT, | ||
session = 1, -- 1 for root init | ||
type = MESSSAGE_SYSTEM, | ||
message = init_msg, | ||
size = sz, | ||
} | ||
end | ||
|
||
local function start(config) | ||
boot.init(config.core) | ||
boot.init_timer() | ||
bootstrap_root(config.root_initfunc, config.root) | ||
return boot.run(config.mainthread) | ||
end | ||
|
||
local function wait(ctx) | ||
boot.wait(ctx) | ||
boot.deinit() | ||
end | ||
|
||
return { | ||
start = start, | ||
wait = wait, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
local ltask = require "ltask" | ||
local logpath = (...).LOGPATH | ||
|
||
local S = {} | ||
|
||
local logfile = io.open(logpath .. '/ltask.log', 'w+b') | ||
if logfile then | ||
logfile:setvbuf("no") | ||
end | ||
|
||
local function writelog() | ||
while true do | ||
local ti, _, msg, sz = ltask.poplog() | ||
if ti == nil then | ||
break | ||
end | ||
local tsec = ti // 100 | ||
local msec = ti % 100 | ||
local level, message = ltask.unpack_remove(msg, sz) | ||
if logfile then | ||
logfile:write(string.format("[%s.%02d][%-5s]%s\n", os.date("%Y-%m-%d %H:%M:%S", tsec), msec, level:upper(), message)) | ||
end | ||
end | ||
end | ||
|
||
ltask.fork(function() | ||
while true do | ||
writelog() | ||
ltask.sleep(100) | ||
end | ||
end) | ||
|
||
function S.quit() | ||
writelog() | ||
end | ||
|
||
return S |
Oops, something went wrong.