[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnetlib ./ChangeLog runtime/System/Threading/Ti...
From: |
Heiko Weiss |
Subject: |
[dotgnu-pnet-commits] pnetlib ./ChangeLog runtime/System/Threading/Ti... |
Date: |
Thu, 19 Jan 2006 11:14:46 +0000 |
CVSROOT: /sources/dotgnu-pnet
Module name: pnetlib
Branch:
Changes by: Heiko Weiss <address@hidden> 06/01/19 11:14:46
Modified files:
. : ChangeLog
runtime/System/Threading: Timer.cs
Log message:
if system time was changed, timers did not run anymore. fixed.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/ChangeLog.diff?tr1=1.2347&tr2=1.2348&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/runtime/System/Threading/Timer.cs.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
Patches:
Index: pnetlib/ChangeLog
diff -u pnetlib/ChangeLog:1.2347 pnetlib/ChangeLog:1.2348
--- pnetlib/ChangeLog:1.2347 Sun Jan 15 06:11:51 2006
+++ pnetlib/ChangeLog Thu Jan 19 11:14:46 2006
@@ -1,3 +1,6 @@
+2006-01-19 Heiko Weiss <address@hidden>
+
+ * runtime/System/Threading/Timer.cs: fixed bug, if system time was
changed
2006-01-15 Rhys Weatherley <address@hidden>
Index: pnetlib/runtime/System/Threading/Timer.cs
diff -u pnetlib/runtime/System/Threading/Timer.cs:1.9
pnetlib/runtime/System/Threading/Timer.cs:1.10
--- pnetlib/runtime/System/Threading/Timer.cs:1.9 Fri Jun 11 07:25:56 2004
+++ pnetlib/runtime/System/Threading/Timer.cs Thu Jan 19 11:14:46 2006
@@ -161,7 +161,7 @@
//
long due = dueTime == -1 ? AlarmClock.INFINITE :
dueTime;
long interval = period <= 0 ? AlarmClock.INFINITE :
period;
- Timer.AdvanceTime();
+ Timer.AdvanceTime(period);
this.alarm.SetAlarm(due, interval);
//
// Wake up the background thread so it sees the new
state.
@@ -295,7 +295,7 @@
long longMs = Timer.alarmClock.TimeTillAlarm;
int ms = longMs > int.MaxValue ? int.MaxValue :
(int)longMs;
Timer.threadWakeup.WaitOne(ms, false);
- Timer.AdvanceTime();
+ Timer.AdvanceTime(ms);
}
}
@@ -303,7 +303,7 @@
// Advance the time in the Alarm object so it is the same as the
// real time.
//
- private static void AdvanceTime()
+ private static void AdvanceTime(long timerPeriod)
{
long elapsed;
lock (typeof(Timer))
@@ -312,6 +312,16 @@
Timer.now = Timer.UtcMilliseconds();
elapsed = Timer.now - was;
}
+ // if elapsed is less then zero the system time might
have been changed to the past.
+ // so dont sleep. This works well.
+ if( elapsed < 0 ) {
+ elapsed = 0;
+ }
+ // if elapsed is greater then x*timerPeriod the system
time might have been changed to the future.
+ // This is a workaround. but works.
+ else if( timerPeriod > 0 && elapsed > 10*timerPeriod ) {
+ elapsed = 0;
+ }
Timer.alarmClock.Sleep(elapsed);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnetlib ./ChangeLog runtime/System/Threading/Ti...,
Heiko Weiss <=