Commit Graph
58 Commits
Author SHA1 Message Date
Marek Safar 5d96c0de63 Simplify work item registration for internal work items 2013-10-09 12:51:16 +02:00
Marek Safar 238785a3e3 Don't eat exception from timer handler (this is system timer not SWF timer) 2013-07-12 17:44:53 +02:00
Marek Safar 6643562a1e Use generics list 2013-03-08 15:47:43 +01:00
Rodrigo Kumpera b96d05dac3 Kill the MOONLIGHT define in corlib. 2013-02-11 16:03:28 -05:00
Rodrigo Kumpera f197c5c9cd [corlib] Handle overflow correctly in Timer to avoid spinning. Fixes #8782
* Timer.cs: Very long timers can lead to timeout values that are
	bigger than Int32.MaxValue, leading to a negative value and us
	spinning.
2013-01-09 16:30:38 -05:00
Marek Safar 7883a2dafd Clean up some static initializers 2012-10-03 12:19:55 +01:00
Rodrigo Kumpera 3fb5e02a64 Fix parameter name in the exception constructor. 2011-12-07 15:19:37 -02:00
Rolf Bjarne Kvinge f64261401d Fix many corcompare issues for moonlight 2011-03-31 16:05:03 +02:00
Jb Evain 31d4e41b63 Revert "Fix the MDr and MT build"
This reverts commit b5c472b320.

We can use the Unsafe optimized variant in mobile.
2011-03-14 21:07:24 +01:00
Jb Evain b5c472b320 Fix the MDr and MT build 2011-03-14 17:20:56 +01:00
Sebastien Pouliot f6f6d3e0e5 Fix mono/mcs build for Moonlight profile
* corlib/System.Threading/Timer.cs:
* System/System.Net.Sockets/Socket_2_1.cs:
	Use API available under Moonlight when MOONLIGHT is defined
2011-03-11 16:20:03 -05:00
Gonzalo Paniagua Javier a2cbc2598e [Timer] Use static CB for invoking timer callbacks. 2011-03-10 19:05:14 -05:00
Gonzalo Paniagua Javier fa67678aaf [Timer] Use a WaitHandle instead of Wait/Pulse
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.
2010-11-20 16:44:41 -05:00
Gonzalo Paniagua Javier fe282179e7 Fix the collision handling code
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.
2010-10-21 00:08:54 -04:00
Gonzalo Paniagua Javier eb2a5490f2 Adapt to new exception in threadpool behavior.
Since an exception in the threadpool can kill the application,
	silently ignore it when we know it is not harmful.
2010-08-11 13:15:39 -04:00
Gonzalo Paniagua Javier 3683a0c596 2010-05-17 Gonzalo Paniagua Javier <[email protected]>
* Timer.cs: check object reference when the timers are equal.
	Fixes bug #605092.


svn path=/trunk/mcs/; revision=157410
2010-05-17 05:05:47 +00:00
Miguel de Icaza 5e63701d4b 2009-11-02 Miguel de Icaza <[email protected]>
* 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-11-02 23:22:40 +00:00
Sebastien Pouliot f3506a6f99 In System.Threading:
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
2009-10-20 15:52:42 +00:00
Gonzalo Paniagua Javier ec80c092b5 2009-10-20 Gonzalo Paniagua Javier <[email protected]>
* Timer.cs: make sure we don't insert 2 timers with the same key.


svn path=/trunk/mcs/; revision=144462
2009-10-20 15:29:04 +00:00
Gonzalo Paniagua Javier 6de52aa290 2009-10-16 Gonzalo Paniagua Javier <[email protected]>
* Timer.cs: looks like any negative value is treated as Infinite.


svn path=/trunk/mcs/; revision=144283
2009-10-16 17:45:09 +00:00
Gonzalo Paniagua Javier 8defce07e3 2009-09-27 Gonzalo Paniagua Javier <[email protected]>
* Timer.cs: account for the time spent sending jobs to the queue.


svn path=/trunk/mcs/; revision=142703
2009-09-27 05:48:08 +00:00
Gonzalo Paniagua Javier e7daab3777 2009-09-24 Gonzalo Paniagua Javier <[email protected]>
* Timer.cs: no need to wake up the scheduler when removing the next
	scheduled item.


svn path=/trunk/mcs/; revision=142547
2009-09-24 04:31:58 +00:00
Gonzalo Paniagua Javier e9fdbea331 comment out debugging method
svn path=/trunk/mcs/; revision=142525
2009-09-23 23:03:52 +00:00
Gonzalo Paniagua Javier 81d05c0ea4 2009-09-23 Gonzalo Paniagua Javier <[email protected]>
* 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
2009-09-23 23:01:03 +00:00
Jb Evain dc7c368828 add comment
svn path=/trunk/mcs/; revision=142420
2009-09-22 16:35:40 +00:00
Jb Evain 0fda7eb8e7 2009-09-22 Jb Evain <[email protected]>
* 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
2009-09-22 15:43:35 +00:00
Miguel de Icaza 1601b10bbf 2009-06-25 Miguel de Icaza <[email protected]>
* Timer.cs: Throw ArgumentNullException if the callback is null. 

svn path=/trunk/mcs/; revision=136912
2009-06-26 00:47:19 +00:00
Paolo Molaro c1b9ae0954 Tue Sep 9 15:19:48 CEST 2008 Paolo Molaro <[email protected]>
* 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
2008-09-09 13:22:31 +00:00
Zoltan Varga 088d0adf92 2008-07-02 Zoltan Varga <[email protected]>
* Timer.cs (SchedulerThread): Iterate through the keys of the hashtable instead
	of key-value pairs.

svn path=/trunk/mcs/; revision=107071
2008-07-02 16:09:32 +00:00
Paolo Molaro eb10fa0c6c Tue Feb 26 17:51:58 CET 2008 Paolo Molaro <[email protected]>
* Timer.cs: use a monotonic clock to schedule timers
	(fixes part of bug#347476).


svn path=/trunk/mcs/; revision=96663
2008-02-26 16:30:33 +00:00
Paolo Molaro 10f5121f53 2007-09-14 Jb Evain <[email protected]>
* Makefile: force the use of the 2.0 mscorlib to compile
	the 2.1 mscorlib.dll.


svn path=/trunk/mcs/; revision=89215
2007-11-08 17:16:46 +00:00
Paolo Molaro 5f6065478f Wed Oct 17 13:24:33 CEST 2007 Paolo Molaro <[email protected]>
* Timer.cs: better cleanup test for the expired array.


svn path=/trunk/mcs/; revision=87649
2007-10-17 11:09:04 +00:00
Paolo Molaro 30285e8c6c Tue Oct 16 17:22:15 CEST 2007 Paolo Molaro <[email protected]>
* Timer.cs: remove expired timers from the the jobs list.


svn path=/trunk/mcs/; revision=87594
2007-10-16 15:05:38 +00:00
Paolo Molaro e12847ece5 Tue Oct 16 12:14:43 CEST 2007 Paolo Molaro <[email protected]>
* 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
2007-10-16 10:00:19 +00:00
Dick Porter 419508e978 2007-09-06 Dick Porter <[email protected]>
* 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
2007-09-06 15:30:17 +00:00
Atsushi Eno 12dbd9ec3f 2004-04-29 Atsushi Enomoto <[email protected]>
* Timer.cs : avoid NullReferenceException when it is already disposed.
	  Patch by [email protected]. Fixed bug #78208.


svn path=/trunk/mcs/; revision=60075
2006-04-29 15:18:50 +00:00
Martin Baulig a0a18f5615 2005-09-09 Martin Baulig <[email protected]>
* Timer.cs (Timer.Runner.Start): Silently catch
	ObjectDisposedException and return; works around some race
	condition on thread abort.	


svn path=/trunk/mcs/; revision=49775
2005-09-09 06:11:03 +00:00
Martin Baulig 65ad2a3b45 2005-07-19 Martin Baulig <[email protected]>
* 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
2005-07-19 06:21:50 +00:00
Sebastien Pouliot 74c0ac4684 2005-05-29 Sebastien Pouliot <[email protected]>
* 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
2005-05-29 14:51:47 +00:00
Raja R Harinath e0cfa4925e Set svn:eol-style=native, delete svn:executable.
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
2005-05-16 12:23:26 +00:00
Gonzalo Paniagua Javier 4c07adad95 2004-09-16 Gonzalo Paniagua Javier <[email protected]>
* Timer.cs: don't invoke the callback twice when the timer changes.
	Fixes bug #66116.

svn path=/trunk/mcs/; revision=33975
2004-09-16 18:33:27 +00:00
Gonzalo Paniagua Javier 5576e9532e 2004-08-04 Gonzalo Paniagua Javier <[email protected]>
* Timer.cs: don't invoke the callback if the period changes before the
	due time. Fixes bug #62421.

svn path=/trunk/mcs/; revision=31873
2004-08-04 16:58:52 +00:00
Lluis Sanchez 6f79c6d07e * Timer.cs: Don't abort the thread if Dispose() is called from the runner
thread.

svn path=/trunk/mcs/; revision=29593
2004-06-15 09:51:58 +00:00
Duncan Mak 13d1764537 Add license and copyright to all source files in corlib
svn path=/trunk/mcs/; revision=29249
2004-06-11 02:09:36 +00:00
Lluis Sanchez 74276c5768 * ThreadPool.cs: Added GetMinThreads and SetMinThreads.
* Timer.cs: In Change, return false if the timer has been disposed.
	In Dispose, notify the WaitHandle.

svn path=/trunk/mcs/; revision=25552
2004-04-15 14:40:58 +00:00
Zoltan Varga 587b8babef 2004-04-09 Zoltan Varga <[email protected]>
* Timer.cs: Call the callback immediately if dueTime is 0. Fixes
	#56728.

svn path=/trunk/mcs/; revision=25245
2004-04-09 13:15:21 +00:00
Gonzalo Paniagua Javier 786e70ee30 2004-04-08 Gonzalo Paniagua Javier <[email protected]>
* Timer.cs: call Abort on the Runner instance too.

svn path=/trunk/mcs/; revision=25206
2004-04-08 04:30:13 +00:00
Gonzalo Paniagua Javier 271bb68c4e 2004-03-21 Gonzalo Paniagua Javier <[email protected]>
* 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
2004-03-21 07:38:16 +00:00
Zoltan Varga 372e2b3af8 2004-03-08 Zoltan Varga <[email protected]>
* Timer.cs (Dispose): Applied patch from Jaroslaw Kowalski
	([email protected]). Fix finalization problems during appdomain unload.

svn path=/trunk/mcs/; revision=23807
2004-03-08 16:24:20 +00:00
Pedro Martínez Juliá f2d32eb17c 2003-04-17 Pedro Mart�nez Juli� <[email protected]>
* 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
2003-04-17 20:35:41 +00:00