awesome/lib/gears
Uli Schlachter 0367af2be9 gears.timer: Add simpler ways to start timers
This adds gears.timer.start(timeout, callback) that creates a timer object and
connects a callback to it, all in one go.

Additionally, this adds gears.timer.weak_start(timeout, callback). The weak
version still allows the callback function to be garbage collected and will then
stop the timer.

This was tested with the following code:

  require("gears.timer").start(0.3, function()
    print("ping")
    if collectgarbage("step", 500) then
      print("collection done")
      error("err")
    end
    return true end)
  require("gears.timer").weak_start(0.1, function()
    io.stdout:write(".")
    return true
  end)

After a full collection cycle, both timers are stopped. The first one is stopped
because of the error() that it generated. The second one is stopped because the
callback function was garbage collected.

Ref: https://github.com/awesomeWM/awesome/issues/216

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-08-12 09:54:55 +02:00
..
cache.lua Add a generic cache system as gears.cache 2015-07-25 15:07:47 +02:00
color.lua Use gears.cache to replace some other caches 2015-07-25 15:08:00 +02:00
debug.lua gears.debug: add support for limited depth 2015-08-01 11:24:35 +02:00
init.lua Add a generic cache system as gears.cache 2015-07-25 15:07:47 +02:00
object.lua wibox.widget.base: add __tostring method to widgets 2015-07-26 18:17:01 +02:00
sort.lua Remove the *.in from all files. 2015-06-19 22:33:32 +02:00
surface.lua Bump required lgi version to 0.7.1 2015-08-11 19:08:35 +02:00
timer.lua gears.timer: Add simpler ways to start timers 2015-08-12 09:54:55 +02:00
wallpaper.lua Remove the *.in from all files. 2015-06-19 22:33:32 +02:00