www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Timers: setInterval and setTimeout

reply "Shripad K" <assortmentofsorts gmail.com> writes:
Hello all,

I'm looking for the right way to implement Javascript-like 
setInterval and setTimeout in D.

I don't want to use multiple threads + sleep as an 
implementation. It needs to be single threaded. I was thinking 
along the lines of creating a timer using ualarm/settimer and 
listening to SIGALARM. I want it to be efficient as i'll be using 
it for timing out HTTP requests.

Can someone guide me in the right direction?

Thanks for any help,
Shripad K.
Aug 01 2012
parent "Shripad K" <assortmentofsorts gmail.com> writes:
Okay really sorry to bother you all. I found a better way of 
dealing with timers. Coupled tango's signal/slot implementation 
with its Selector abstraction (with timeout) and things work like 
a charm.

On Wednesday, 1 August 2012 at 18:15:44 UTC, Shripad K wrote:
 Hello all,

 I'm looking for the right way to implement Javascript-like 
 setInterval and setTimeout in D.

 I don't want to use multiple threads + sleep as an 
 implementation. It needs to be single threaded. I was thinking 
 along the lines of creating a timer using ualarm/settimer and 
 listening to SIGALARM. I want it to be efficient as i'll be 
 using it for timing out HTTP requests.

 Can someone guide me in the right direction?

 Thanks for any help,
 Shripad K.

Aug 01 2012