Exemplo n.º 1
0
Bool SemaImplementationTimedWait(void* Data, const TimeSpan& timeout)
{
  timeval t;
  gettimeofday(&t, 0);
  RF_Type::UInt64 end =
      t.tv_sec * 10000000llu + t.tv_usec * 10llu + timeout.Ticks();
  timespec atTime;
  atTime.tv_sec = end / TimeSpan::TicksPerSecond;
  atTime.tv_nsec = end - atTime.tv_sec * TimeSpan::TicksPerSecond;

#ifdef RF_OSX
  time_t timer = time(NULL) * 1000 + end;
  int res = 0;
  do
  {
    res = sem_trywait(static_cast<sem_t*>(Data));
    if(res == 0)
      break;
    sleep(1);
  } while(time(NULL) * 1000 < timer);
#else
  int res = sem_timedwait(static_cast<sem_t*>(Data), &atTime);
#endif
  return res == 0;
}
Exemplo n.º 2
0
		void Thread::Sleep(TimeSpan timeout)
		{
			if(timeout == TimeSpan::Zero)
				return; //! no reason to sleep

			LARGE_INTEGER pli;

			pli.QuadPart = -timeout.Ticks();
			KeDelayExecutionThread((KPROCESSOR_MODE)0, FALSE, &pli);
		}
Exemplo n.º 3
0
 constexpr TimeSpan operator-(TimeSpan ts)
 {
     return TimeSpan(-ts.Ticks());
 }
Exemplo n.º 4
0
 constexpr TimeSpan operator-(TimeSpan a, TimeSpan b)
 {
     return TimeSpan(a.Ticks() - b.Ticks());
 }
Exemplo n.º 5
0
 constexpr bool operator>=(TimeSpan a, TimeSpan b)
 {
     return a.Ticks() >= b.Ticks();
 }
Exemplo n.º 6
0
 constexpr bool operator<(TimeSpan a, TimeSpan b)
 {
     return a.Ticks() < b.Ticks();
 }