Commit 8b74b9de authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Win32: mwait and msleep are cancellation points

Use SleepEx so APC can be executed
parent 5e7e11d9
...@@ -340,8 +340,19 @@ void mwait( mtime_t date ) ...@@ -340,8 +340,19 @@ void mwait( mtime_t date )
ts.tv_sec = d.quot; ts.tv_nsec = d.rem * 1000; ts.tv_sec = d.quot; ts.tv_nsec = d.rem * 1000;
while( clock_nanosleep( CLOCK_REALTIME, 0, &ts, NULL ) == EINTR ); while( clock_nanosleep( CLOCK_REALTIME, 0, &ts, NULL ) == EINTR );
} }
#else
#elif defined (WIN32)
mtime_t total;
while ((total = (date - mdate ())) > 0)
{
DWORD delay = (total > 0x7fffffff) ? 0x7fffffff : total;
vlc_testcancel ();
SleepEx (delay, TRUE);
}
vlc_testcancel ();
#else
mtime_t delay = date - mdate(); mtime_t delay = date - mdate();
if( delay > 0 ) if( delay > 0 )
msleep( delay ); msleep( delay );
...@@ -350,9 +361,8 @@ void mwait( mtime_t date ) ...@@ -350,9 +361,8 @@ void mwait( mtime_t date )
} }
/** /**
* More precise sleep() * Portable usleep(). Cancellation point.
* *
* Portable usleep() function.
* \param delay the amount of time to sleep * \param delay the amount of time to sleep
*/ */
void msleep( mtime_t delay ) void msleep( mtime_t delay )
...@@ -373,9 +383,7 @@ void msleep( mtime_t delay ) ...@@ -373,9 +383,7 @@ void msleep( mtime_t delay )
snooze( delay ); snooze( delay );
#elif defined( WIN32 ) || defined( UNDER_CE ) #elif defined( WIN32 ) || defined( UNDER_CE )
for (delay /= 1000; delay > 0x7fffffff; delay -= 0x7fffffff) mwait (mdate () + delay);
Sleep (0x7fffffff);
Sleep (delay);
#elif defined( HAVE_NANOSLEEP ) #elif defined( HAVE_NANOSLEEP )
struct timespec ts_delay; struct timespec ts_delay;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment