-
Notifications
You must be signed in to change notification settings - Fork 0
ams:exec()
Captain Spaulding edited this page Oct 6, 2021
·
30 revisions
This method creates a task, which will run a given function, and inserts it in the kernel queue, handled by the kernel main process. It returns the pointer to the task object created and the task's ID number in the queue.
<task>, <taks_ID> = ams:exec(<function_to_call>, <description>, [<loop_queue>], [<opt_arg>])
-
<funtion_to_call>- the pointer to the function that will be called at each iteration; -
<description>- a string containing the name that will appear in the status informations; -
[<loop_queue>]- optional, the background loop where the task should be inserted, it defaults toams.C.FRAME_LOOP; (see ams.C) -
[<opt_arg>]- optional, custom arguments to be used in the function's body.
-
<task>- a pointer to the task object; (see core.class.task) -
<task_ID>- the task unique identification number.
require('ams')
| type | description | |
|---|---|---|
<task>:exec() |
method | Executes the function (typically used by the kernel scheduler) |
<task>:kill() |
method | Kill it self |
<task>:pause() |
method | Pauses the task indefinitively |
<task>:resume() |
method | Resumes the execution once paused |
<task>:hi_priority() |
method | Sets the process as 'hi-priority' |
<task>:low_priority() |
method | Sets the process as 'low-priority' |
<task>:set_queue(queue) |
method | Move the process to the given queue (see kernel constants) |
<task>:set_arg(el) |
method | Sets the arg variable to
|
<task>.arg |
variable | Holds any kind of user value or array |
require('ams')
local function my_funct(self)
print("Hello world.")
self:kill() --> kills itself
end
local my_task = ams:exec(my_funct, "My Test Function")require('ams')
local function my_funct(self)
print("Hello world.")
self:kill() --> kills itself
end
local function repetitive_task(self)
ams:exec(my_funct, "My Test Function", ams.C.OFTEN_LOOP) --> every second
end
ams:exec(repetitive_task, "My Neverending Loop", ams.C.SOMETIMES_LOOP) --> every 10 secondrequire('ams')
local function my_counter(self)
if self.parm == 0 then
print("Let's Start.")
elseif self.parm == 10 then
print("Ten.")
elseif self.parm == 20 then
print("Twenty.")
elseif self.parm > 30 then
self.kill()
end
self.parm = self.parm + 1
end
ams:exec(my_counter, "My Counter is counting...", ams.C.OFTEN_LOOP, 0)require('ams')
local function slave_process(self)
print("Hello World!")
end
local function master_process(self)
if self.parm.count == 10 then
self.parm.slave:pause()
elseif self.parm.count == 20 then
self.parm.slave:resume()
elseif self.parm.count > 30 then
self.parm.slave:kill()
self:kill()
end
self.parm.count = self.parm.count + 1
end
local slave = ams:exec(slave_process, "Slave process", ams.C.FRAME_LOOP)
local master = ams:exec(master_process, "Master process", ams.C.OFTEN_LOOP, {count = 0, slave = slave})AMS an Advanced Library Package for FlyWithLua
Updated to v.1.55a (private alpha)
Copyright (C) 2021 Pasquale Croce
- ams.core.kernel
-
ams.core.dref_mgr
- ams:create_dref()
- ams:create_command()
- ams:map_dref()
- ams.core.wm
- ams:register_window()
- ams.core.for_loop
- ams:for_loop()
- ams.core.spc
- ams:spc()
-
ams.core.procs_mon
- ams:procs_mon()
- ams.core.debug
- ams.core.config
- ams.sys.info
- ams.sys.timer
- ams.sys.win.timer
- ams.SDK.XPML
- ams.SDK.scenery
- ams.SDK.map
- ams.SDK.datarefs
- ams.SDK.AIplanes
- ams.SDK.menus
- ams.SDK.processing
- ams.SDK.graphics
- ams.xlua.math
- ams.xlua.strings
- ams.xlua.table
- ams.xlua.Vec2D
- ams.xlua.Const
- ams.xlua.Stack
- ams.carillon.carillon
- ams.utils.tts
- ams.install.loader