Notifications of changes were sent using Monitor.Pulse() while the
scheduler thread was in a Monitor.Wait(). The way we handle
Monitor.Wait() internally involves creating an manual-reset event and
waiting on it each time Monitor.Wait() is called.
With this change, one 1 event is created for the lifetime of the
appdomain. These seems to help avoiding contention when there are a lot
of timers in play.
After the fix for bug #605092, inserting timers with an equal due time
was failing because searching in the list was also using a reference
comparison. Now, when adding a new timer, we search using just the due
time.
Fixes bug #648130.
* Jumbo patch to drop support for pre-NET_2_0 code:
Remove ONLY_1_1 code
Remove NET_1_0 only code
Remove NET_2_0 defines assuming the value is true.
svn path=/trunk/mcs/; revision=145230
2009-10-20 Sebastien Pouliot <[email protected]>
* Timer.cs: Always call Init from every constructors to avoid
duplicate checks. Fix validations on different dueTime and period
(ctor and Change methods). Seal private TimerComparer class and
avoid multiple (identical) casts in its Compare method. Seal
private Scheduler class.
In Test/System.Threading:
2009-10-20 Sebastien Pouliot <[email protected]>
* TimerTest.cs: Add more validation tests
svn path=/trunk/mcs/; revision=144466
* Timer.cs: rewritten. It only has one queue now and it is sorted by
due time. Before this changes, it was using a lot of CPU when there
were a lot of 'future' timers.
svn path=/trunk/mcs/; revision=142524
* Timer.cs: MONOTOUCH doesn't support remoting, so do not pass
true to exitContext when calling WaitOne on a WaitHandle.
svn path=/trunk/mcs/; revision=142411
* Timer.cs: use a separate queue for timers that are far in the future
so they don't need to be looked at as often (bug #418272).
Better precision of recheduling time.
svn path=/trunk/mcs/; revision=112584
* Timer.cs: rewrote to use threadpool threads to invoke the callbacks,
avoid Thread.Abort and Thread.Interrupt and use a single scheduler
thread, partially from the patch of Rafael Ferreira in bug #315999.
Fixes bug #315999, #332206.
svn path=/trunk/mcs/; revision=87565
* Timer.cs: Only hold a WeakReference to the runner thread, to
work around an issue when finalizing at shutdown or (I think)
appdomain unload. (Basically, the Thread was being finalized
first, but the Timer's finalizer was still trying to reference it
subsequently.)
svn path=/trunk/mcs/; revision=85425
* Timer.cs : avoid NullReferenceException when it is already disposed.
Patch by [email protected]. Fixed bug #78208.
svn path=/trunk/mcs/; revision=60075
* Timer.cs (Timer.Runner.Start): Silently catch
ObjectDisposedException and return; works around some race
condition on thread abort.
svn path=/trunk/mcs/; revision=49775
* Timer.cs (Timer.Runner.Start): Fix a race condition which was
causing a hang on exit int he debugger: check `!disposed' before
`start_event.WaitOne ()' and again after it.
svn path=/trunk/mcs/; revision=47401
* Timer.cs: Added new constructor for 2.0 and ComVisible attribute.
* Timeout.cs: This is a static class in 2.0 and ComVisible attribute.
svn path=/trunk/mcs/; revision=45164
Fix line endings of System/Decimal.cs (only actual "change" in text, to force recompile of mscorlib to reflect changes in decimal constant handling in the compiler)
svn path=/trunk/mcs/; revision=44558
* ThreadAbortException.cs: use same HResult as MS.
* Timer.cs: abort the running thread when disposing the Timer. This
fixes NullRefs when finishing xsp.
svn path=/trunk/mcs/; revision=24386
* Timer.cs: Change the position of two lines because they were
before the "if" that ensures the integrity. After this, the first of
that two lines was producing a NullReferenceException.
svn path=/trunk/mcs/; revision=13737