Skip to content

Commit

Permalink
Add engine.stop() to stop all apps.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukego committed Jul 30, 2018
1 parent 46e0e4a commit dc4cb79
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ following keys are recognized:
printed.


— Function **engine.stop**

Stop all apps in the engine by loading an empty configuration.

— Function **engine.now**

Returns monotonic time in seconds as a floating point number. Suitable
Expand Down
11 changes: 11 additions & 0 deletions src/core/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ function configure (new_config)
counter.add(configs)
end


-- Stop all apps by loading an empty configuration.
function stop ()
configure(config.new())
end

-- Removes the claim on a name, freeing it for other programs.
--
-- This relinquish a claim on a name if one exists. if the name does not
Expand Down Expand Up @@ -721,6 +727,11 @@ function selftest ()
main({duration = 4, report = {showapps = true}})
assert(app_table.app3 ~= orig_app3) -- should be restarted

-- Check engine stop
assert(not lib.equal(app_table, {}))
engine.stop()
assert(lib.equal(app_table, {}))

-- Check one can't unclaim a name if no name is claimed.
assert(not pcall(unclaim_name))

Expand Down

0 comments on commit dc4cb79

Please sign in to comment.