spin() and Win32 port

Ranjit Mathew rmathew@hotmail.com
Thu Dec 19 03:41:00 GMT 2002


Tom Tromey wrote:
> I let in a small change to natObject.cc that changed spin() to call
> Thread::sleep instead of usleep().
> 
> I think this was a mistake (to be honest I don't recall seeing that
> code in a patch, double oops on me).  spin() is used in the

It was let in via this patch:

http://gcc.gnu.org/ml/java-patches/2002-q4/msg00073.html

BTW, notice that Thread::sleep takes nanoseconds in the
second parameter, but is being passed a microseconds
value...

I could find only millisecond granularity for Win32
timers - the Win32 Sleep( ) function takes the number
of milliseconds to sleep. The usleep( ) function takes
the number of microseconds to sleep and is not defined
at all in MSVCRT (and therefore MinGW).

The SetWaitableTimer Win32 function does provide a
100-nanosecond granularity, but would not work on Win95. :-(

If waiting for a millisecond or more is OK (note:
MAX_SLEEP_USECS is 200000 us = 200 ms, MIN_SLEEP_USECS
is 2001 us = 2 ms), I guess we can use the Win32 Sleep
function.

Ranjit.

-- 
Ranjit Mathew          Email: rmathew AT hotmail DOT com

Bangalore, INDIA.      Web: http://ranjitmathew.tripod.com/





More information about the Java mailing list