Commit Graph

10 Commits

Author SHA1 Message Date
Uli Schlachter 8c26e2dab4 Fix all luacheck warnings in lib/gears
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-12 09:11:50 +01:00
Uli Schlachter a69d901c64 Add some documentation to gears.timer
It feels weird to document the signals like this, but apparently that is the way
this needs to be done.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-11-01 17:08:20 +01:00
Uli Schlachter b61026310d gears.timer: Add start and stop signals (#348)
This makes the timer emit signals for when it is started and stopped. This does
not add a signal for :again(), because that function just calls the other two
functions and thus already emits start and stop.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-18 15:31:52 +02:00
Daniel Hahler 4bffa7e47e doc: fix unintentional rendering as code due to indent 2015-10-14 00:22:26 +02:00
Uli Schlachter 56c22cde77 Merge branch 'widget_context' 2015-08-23 15:33:43 +02:00
Uli Schlachter d122b825ee gears.timer: Fix the traceback on errors
With the second argument being 2, the traceback will not include the error
handling function, but instead end at the actual place of the error.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-08-12 11:17:48 +02:00
Uli Schlachter 74276b3a11 gears.timer: Add a note about GC'ing timers
Ref: https://github.com/awesomeWM/awesome/issues/216

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-08-12 09:54:58 +02:00
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
Daniel Hahler dc9295d981 gears.timer: use xpcall with timeout and delayed calls
This provides a traceback in case of errors.

Ref: https://github.com/awesomeWM/awesome/issues/301
2015-07-22 13:52:47 +02:00
Julian Wollrath 6cc7be512c Remove the *.in from all files.
Signed-off-b: Julian Wollrath <jwollrath@web.de>
2015-06-19 22:33:32 +02:00