nanogui: Thread: Timer API.


[<<] [<] Page 1 of 1 [>] [>>]
Subject: Timer API.
From: Chris Johns ####@####.####
Date: 2 Feb 2000 07:59:14 -0000
Message-Id: <3897E177.44FE39D5@acm.org>

Hello,

I need to have some timers in my application. 

What is the API ?

Does anyone have an example ?

Regards


-- 
 Chris Johns, ####@####.####
Subject: Re: Timer API.
From: Kyle Harris ####@####.####
Date: 2 Feb 2000 14:42:05 -0000
Message-Id: <38983F5E.3C45B1FB@nexus-tech.net>


Chris Johns wrote:
> 
> Hello,
> 
> I need to have some timers in my application.
> 
> What is the API ?
>
I don't think Microwindows provides for anything like this. Are you
running Linux (unix)? If so, you can use signal() and alarm() for low
resolution timers. select() and setitimer() can be used for higher
resolutions.
 
> Does anyone have an example ?
>

See the man pages for the above functions.  

Normally, you set up a signal handler for the SIGALRM and use alarm to
start timers.

main()
{
	signal(SIGLARM,sigalrm);
	alarm(5);
	for(;;);
}

void
sigalrm(int signo)
{
	printf("signal from alarm\n");
}

The above timer will pop in 5 seconds.

Later, Kyle.
Subject: Re: Timer API.
From: "Greg Haerr" ####@####.####
Date: 2 Feb 2000 17:19:30 -0000
Message-Id: <042e01bf6da0$261d1ba0$15320cd0@gregh>

: I need to have some timers in my application. 
: 
: What is the API ?
: 
: Does anyone have an example ?

The timer API is SetTimer() and KillTimer(), which sends
a WM_TIMER message to your window procedure.  I would
prefer to add this, since it's a little tricky.  I've been meaning to 
add it for some time.  

Basically, we will use the select() timeout value in order to delay for
a next-timeout minimum value, then, if a timer is expiring, send a WM_TIMER
message and remove it from the queue.

I can probably get this in quickly, but you're welcome to take
a hack at it.

Regards,

Greg

Subject: Re: Timer API.
From: "Greg Haerr" ####@####.####
Date: 2 Feb 2000 17:25:40 -0000
Message-Id: <045e01bf6da1$003811a0$15320cd0@gregh>

: I don't think Microwindows provides for anything like this. Are you
: running Linux (unix)? If so, you can use signal() and alarm() for low
: resolution timers. select() and setitimer() can be used for higher
: resolutions.
:  
: > Does anyone have an example ?
: >
: 
: See the man pages for the above functions.  
: 
: Normally, you set up a signal handler for the SIGALRM and use alarm to
: start timers.

Kyle's code could work, but that's not how we want to do it,
since Win32 requires millisecond timers, min resolution 25ms.
So we'll have to use select().  And it will have to be the main select().
We want all events to come thru the microwindows main loop, so
we don't want to use alarm, signal, or setitimer...

Greg

Subject: Re: Timer API.
From: Kyle Harris ####@####.####
Date: 2 Feb 2000 18:39:08 -0000
Message-Id: <389876F2.82AEA2A6@nexus-tech.net>


Greg Haerr wrote:
> 
> : I don't think Microwindows provides for anything like this. Are you
> : running Linux (unix)? If so, you can use signal() and alarm() for low
> : resolution timers. select() and setitimer() can be used for higher
> : resolutions.
> :
> : > Does anyone have an example ?
> : >
> :
> : See the man pages for the above functions.
> :
> : Normally, you set up a signal handler for the SIGALRM and use alarm to
> : start timers.
> 
> Kyle's code could work, but that's not how we want to do it,
> since Win32 requires millisecond timers, min resolution 25ms.
> So we'll have to use select().  And it will have to be the main select().
> We want all events to come thru the microwindows main loop, so
> we don't want to use alarm, signal, or setitimer...
> 

Ooooppps... I guess this is my unix (vs. windows) background showing :(.
Will Nano-X also have a timer API added, or is this just for
Microwindows?

Just out of curiosity, how do you plan to use select() since this will
block until the timeout expires?

BTW. The article posted at linuxdevices.com was great! 

Kyle.
Subject: RE: Timer API.
From: Greg Haerr ####@####.####
Date: 2 Feb 2000 19:33:04 -0000
Message-Id: <C1962B36D9BBD311B0F80060083DFEFB054966@SYS.CenSoft.COM>

: Ooooppps... I guess this is my unix (vs. windows) background showing :(.
: Will Nano-X also have a timer API added, or is this just for
: Microwindows?

I suggest that the Nano-X timer api be similar, but have an event
sent that is returned by GrGetNextEvent().


: 
: Just out of curiosity, how do you plan to use select() since this will
: block until the timeout expires?
: 

Select()'s timeout value is set as follows:
	if no timers present, set to 0 (infinite wait)
	if timers present, set the timeout equal to the
amount of timeout left in the smallest timer.



: BTW. The article posted at linuxdevices.com was great! 

Thanks.  There's quite a bit more plans for more press, so stay tuned!

Greg
Subject: Re: Timer API.
From: Chris Johns ####@####.####
Date: 2 Feb 2000 21:38:36 -0000
Message-Id: <3898A17F.93BE429D@acm.org>

Greg Haerr wrote:
> 
> : I need to have some timers in my application.
> :
> : What is the API ?
> :
> : Does anyone have an example ?
> 
> The timer API is SetTimer() and KillTimer(), which sends
> a WM_TIMER message to your window procedure.  I would
> prefer to add this, since it's a little tricky.  I've been meaning to
> add it for some time.
> 

Could you please provide the extact detail for me to work with eg
prototypes, message number etc. ?

It would be nice to be able to pass a pointer to a timer struct and
LPARAM of the message.

> Basically, we will use the select() timeout value in order to delay for
> a next-timeout minimum value, then, if a timer is expiring, send a WM_TIMER
> message and remove it from the queue.
> 

The select side of things is ok. A delta list looks like a good fit. You
need to search the list to insert a timer, how-ever the main loop is
easy (sort of), and the kill timer is also easy (double linked list).

> I can probably get this in quickly, but you're welcome to take
> a hack at it.
> 

I need this feature ASAP so I am happy to do it.

-- 
 Chris Johns, ####@####.####
[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.