IIRC, it does a nasty busy-wait. I did implement another version of ThreadedRepeat some time ago to resolve this problem but then forgot about it. I could try to dig it up but changing the Sleep will be good enough for now. The effective difference between a polling version with Sleep (with strictly positive wait time) and a blocking version with locks will be practically indistinguishable for most users.
Jeff. -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Julián Hidalgo Sent: Friday, June 22, 2007 4:27 PM To: [email protected]; [EMAIL PROTECTED] Subject: MbUnit Re: ThreadedRepeat attribute cause high cpu utilization. Hi > Sure I will do that. I think it would be a good idea to store the wait > salue in the .config file instead of hardcoded the value. What do you > think? > Is there an object were all .config values are stored? It looks like nobody has applied the patch (it's in http://www.mertner.com/jira/browse/MBUNIT-134 by the way). I reviewed it and it seems to work, but I'm not sure why really. Maybe somebody with more knowledge of threading can tell me why. There are 3 calls to Thread.Sleep(0) in the ThreadCollectionRunner. I tried 3 things: - Changing the 0 to 10 one at a time (to see if it was a single call the responsible of the high CPU utilization): still high CPU utilization, but at different stages. - Removing all the calls: no effect, still high CPU utilization - Using different values (1, 10, 100): almost zero CPU utilization. So it looks like the Thread.Sleep(0) calls need to be there, with any value greater than zero, but why? I'm afraid of applying the patch without knowing if it's going to screw something. Also how do we test this? We don't have CPU load monitors. Another thing I find strange is this loop: public void WaitForFinishing() { bool alive = true; while (alive && this.Threads.Count>0) { alive=false; foreach(Thread thread in this.Threads) { if (thread.IsAlive) { this.Threads.Remove(thread); alive=true; break; } } //Thread.Sleep(0); } } If the method is called WaitForFinishing() why is it removing threads that are alive? Makes no sense for me. The same thing it's being done in a method called WaitForFinishingSafe(), but within a try/catch block. > Is there an object were all .config values are stored? I'd rather add a new property to the ThreadedRepeatAttribute attribute than using a configuration file, unless Andy decides we should use one. Julian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MbUnit.User" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/MbUnitUser?hl=en -~----------~----~----~----~------~----~------~--~---
