@@ -27,15 +27,6 @@ The zclock class provides essential sleep and system time functions, used
2727to slow down threads for testing, and calculate timers for polling. Wraps
2828the non-portable system calls in a simple portable API.
2929@discuss
30- This class contains some small surprises. Most amazing, win32 did an API
31- better than POSIX. The win32 Sleep() call is not only a neat 1-liner, it
32- also sleeps for milliseconds, whereas the POSIX call asks us to think in
33- terms of nanoseconds, which is insane. I've decided every single man page
34- for this library will say "insane" at least once. Anyhow, milliseconds
35- are a concept we can deal with. Seconds are too fat, nanoseconds too
36- tiny, but milliseconds are just right for slices of time we want to work
37- with at the 0MQ scale. zclock doesn't give you objects to work with, we
38- like the czmq class model but we're not insane. There, got it in again.
3930The Win32 Sleep() call defaults to 16ms resolution unless the system timer
4031resolution is increased with a call to timeBeginPeriod() permitting 1ms
4132granularity.
@@ -52,9 +43,10 @@ granularity.
5243static int64_t
5344s_filetime_to_msec (const FILETIME * ft )
5445{
55- // As per Windows documentation for FILETIME, copy the resulting FILETIME structure to a
56- // ULARGE_INTEGER structure using memcpy (using memcpy instead of direct assignment can
57- // prevent alignment faults on 64-bit Windows).
46+ // As per Windows documentation for FILETIME, copy the resulting FILETIME
47+ // structure to a ULARGE_INTEGER structure using memcpy (using memcpy
48+ // instead of direct assignment can prevent alignment faults on 64-bit
49+ // Windows).
5850 ULARGE_INTEGER dateTime ;
5951 memcpy (& dateTime , ft , sizeof (dateTime ));
6052
@@ -75,11 +67,12 @@ zclock_sleep (int msecs)
7567 t .tv_nsec = (msecs % 1000 ) * 1000000 ;
7668 nanosleep (& t , NULL );
7769#elif (defined (__WINDOWS__ ))
78- // Windows XP/2000: A value of zero causes the thread to relinquish the
79- // remainder of its time slice to any other thread of equal priority that is
80- // ready to run. If there are no other threads of equal priority ready to run,
81- // the function returns immediately, and the thread continues execution. This
82- // behavior changed starting with Windows Server 2003.
70+ // Windows XP/2000: A value of zero causes the thread to relinquish the
71+ // remainder of its time slice to any other thread of equal priority that
72+ // is ready to run. If there are no other threads of equal priority ready
73+ // to run, the function returns immediately, and the thread continues
74+ // execution. This behavior changed starting with Windows Server 2003.
75+
8376# if defined (NTDDI_VERSION ) && defined (NTDDI_WS03 ) && (NTDDI_VERSION >= NTDDI_WS03 )
8477 Sleep (msecs );
8578# else
0 commit comments