[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Can't Lua ever sleep?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 6 Mar 2017 13:24:41 +0200
2017-03-06 8:52 GMT+02:00 Daurnimator <quae@daurnimator.com>:
> On 6 March 2017 at 17:39, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>> 2017-03-06 8:35 GMT+02:00 Daurnimator <quae@daurnimator.com>:
>>> On 6 March 2017 at 17:31, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>>>> 2017-03-06 7:53 GMT+02:00 Sean Conner <sean@conman.org>:
>>>>> It was thus said that the Great Dirk Laurie once stated:
>>>>>> I've searched the manual for "sleep", "wait", "pause", "delay"
>>>>>> and not found any except the pauses of the GC. Does it have
>>>>>> a different name or must I load some module?
>>>>>
>>>>> In the context of POSIX:
>>>>>
>>>>> sleep() pause execution for a given amount of time
>>>>> wait() pause execution until a child process exits
>>>>> pause() pause execution until a signal happens
>>>>> delay there is no spoon
>>>>>
>>>>> -spc (So what exactly are you trying to achieve?)
>>>>
>>>> A semi-animated slideshow in lcurses. I have a Turbo Pascal
>>>> mindset when it comes to fullscreen text apps. Unit Crt used to
>>>> have a "Delay", lcurses seems not to.
>>>
>>> Do you actually want to sleep for X seconds?
>>> Or do you want to sleep for X seconds *or* until input is received?
>>> (e.g. to allow pressing 'space' to go forwards a slide manually)
>>
>> I can imagine that one would crave for the latter sooner or later,
>> although for now the former will do.
>
> For just sleeping, you have lots of options:
>
> - os.execute(string.format("sleep %d", X))
> - require "unix".sleep(X)
> - require "posix".sleep(X)
> - require "cqueues".sleep(X)
> - require "socket".sleep(X)
>
> However if you want to also wait on input, you'll need to be more choosy:
>
> - require "cqueues".poll({pollfd=0--[[for stdin]]}, X)
> - require "socket".select({some_fake_socket}, {}, X)
> - require "unix".poll({{fd=0; events=1}}, 1)
>
> Personally I always just start with cqueues now: the only reason I
> wouldn't is if I needed to support windows.
Actually, now that I am reading the lcurses documentation properly,
the required function is there already: halfdelay(). It sets up a delay
that is cut short if you press a key.