Commit 7d1ceaf7 authored by Sean McBride's avatar Sean McBride
Browse files

BUG: replace vtkSleep with SystemTools::Delay

parent 7a6b5144
#include "vtkConditionVariable.h"
#include "vtkMultiThreader.h"
#include "vtksys/SystemTools.hxx"
#include <stdlib.h>
// For vtkSleep
#include "vtkWindows.h"
#include <ctype.h>
#include <time.h>
// Cross platform sleep
inline void vtkSleep( double duration )
{
// sleep according to OS
#ifdef _WIN32
Sleep( (int)( 1000 * duration ) );
#elif defined(__FreeBSD__) || defined(__linux__) || defined(sgi) || defined(__APPLE__)
struct timespec sleep_time, dummy;
sleep_time.tv_sec = static_cast<int>( duration );
sleep_time.tv_nsec = static_cast<int>( 1000000000 * ( duration - sleep_time.tv_sec ) );
nanosleep( &sleep_time, &dummy );
#else
(void)duration;
#warning Missing sleep implementation
#endif
}
typedef struct {
vtkMutexLock* Lock;
......@@ -69,7 +49,7 @@ VTK_THREAD_RETURN_TYPE vtkTestCondVarThread( void* arg )
cout.flush();
td->Lock->Unlock();
td->Condition->Broadcast();
vtkSleep( 0.2 ); // 0.2 s between broadcasts
vtksys::SystemTools::Delay( 200 ); // 0.2 s between broadcasts
}
while ( td->NumberOfWorkers > 0 && ( i ++ < 1000 ) );
if ( i >= 1000 )
......@@ -82,7 +62,7 @@ VTK_THREAD_RETURN_TYPE vtkTestCondVarThread( void* arg )
// Wait for thread 0 to initialize... Ugly but effective
while ( td->Done < 0 )
{
vtkSleep( 0.2 ); // 0.2 s between checking
vtksys::SystemTools::Delay( 200 ); // 0.2 s between checking
}
// Wait for the condition and then note we were signaled.
......
......@@ -34,32 +34,6 @@
#include <vtksys/stl/utility>
#include <vtksys/stl/vector>
// For vtkSleep
#include "vtkWindows.h"
#include <ctype.h>
#include <time.h>
#if _WIN32
#include "windows.h"
#endif
//-----------------------------------------------------------------------------
// Cross platform sleep
inline void vtkSleep(double duration)
{
// sleep according to OS
#ifdef _WIN32
Sleep( (int)( 1000 * duration ) );
#elif defined(__FreeBSD__) || defined(__linux__) || defined(sgi) || defined(__APPLE__)
struct timespec sleep_time, dummy;
sleep_time.tv_sec = static_cast<int>( duration );
sleep_time.tv_nsec = static_cast<int>( 1000000000 * ( duration - sleep_time.tv_sec ) );
nanosleep( &sleep_time, &dummy );
#else
(void)duration;
#warning Missing sleep implementation
#endif
}
VTK_THREAD_RETURN_TYPE vtkGeoSourceThreadStart(void* arg)
{
vtkGeoSource* self;
......
......@@ -25,10 +25,7 @@
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkTimerLog.h"
#include "vtkUnsignedCharArray.h"
#include "vtkWindows.h"
#include <ctype.h>
#include <time.h>
#include "vtksys/SystemTools.hxx"
//---------------------------------------------------------------
// Important FrameBufferMutex rules:
......@@ -462,24 +459,6 @@ void vtkVideoSource::InternalGrab()
this->FrameBufferMutex->Unlock();
}
//----------------------------------------------------------------------------
// Cross platform sleep
static inline void vtkSleep(double duration)
{
// sleep according to OS
#ifdef _WIN32
Sleep( (int)( 1000 * duration ) );
#elif defined(__FreeBSD__) || defined(__linux__) || defined(sgi) || defined(__APPLE__)
struct timespec sleep_time, dummy;
sleep_time.tv_sec = static_cast<int>( duration );
sleep_time.tv_nsec = static_cast<int>( 1000000000 * ( duration - sleep_time.tv_sec ) );
nanosleep( &sleep_time, &dummy );
#else
(void)duration;
#warning Missing sleep implementation
#endif
}
//----------------------------------------------------------------------------
// Sleep until the specified absolute time has arrived.
// You must pass a handle to the current thread.
......@@ -492,7 +471,7 @@ static int vtkThreadSleep(vtkMultiThreader::ThreadInfo *data, double time)
double remaining = time - vtkTimerLog::GetUniversalTime();
// check to see if we have reached the specified time
if (remaining <= 0)
if (remaining <= 0.0)
{
if (i == 0)
{
......@@ -516,7 +495,7 @@ static int vtkThreadSleep(vtkMultiThreader::ThreadInfo *data, double time)
break;
}
vtkSleep(remaining);
vtksys::SystemTools::Delay(remaining * 1000.0);
}
return 0;
......
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