Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] non blocking sleep

Hi Carl,

I think it depends a bit on the language you are using - which are you using?

I have personally found JavaScript much easier for this type of problem because it is non-blocking by default. But it is perfectly possible in other languages too. You basically have to avoid calling sleep and use timers instead.


> On 5 Oct 2019, at 03:08, Carl Karsten <carl@xxxxxxxxxxxxxxxx> wrote:
> or how to schedule something to happen X seconds later.
> There has to be a pattern to handle "this" although I'm struggling to understand/define exactly what this is I'm having trouble with.
> When the door opens, the light should stay on for 60 seconds.
> or if the button is pressed, turn the light off 30 seconds later.
> every door open resets the 60 seconds.
> (this is the simplified version that I think is the root of my problem) 
> control system:
> master process keeps track of the state of doors and lights.
> doors and lights don't know state.  
> doors and buttons send activity messages, lights listen for on/off messages.
> door sensor sends "open" message.
> master's on_open sends "light on" message and stores the time.
> on_buitton sends "light off"
> I can't do "on, sleep(60), off" because that will block the on_button (right?)
> and when the button is pressed, if the door opens again that should disable the "off in 30" thing.
> Is there a tutorial page or something I should be reading? 
> -- 
> Carl K
> _______________________________________________
> paho-dev mailing list
> paho-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top