• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: thread spinning ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: thread spinning ...


  • Subject: Re: thread spinning ...
  • From: Martin Redington <email@hidden>
  • Date: Wed, 6 Dec 2006 04:50:16 +0000


Ah. That might just be the other half of the jigsaw puzzle.

I just added some logging to see how quickly the loop was getting executed, and was lucky enough to hit it, and it turns out was running every few microseconds.

Ironically enough, until recently, I was adding a port to the runloop manually, in the vain hope that I could remove it later, and have the loop stop. I took it out because it looked like a hack, didn't work, and I thought it might be part of the mach_port leakage I posted about earlier.

That kind of implies that my thread might usually have some input sources attached when it completes, but occasionally doesn't. Is there any way to inspect the runloop and tell what the sources are? That would be very useful, both in terms of understanding what's going on under the hood, and maybe in detecting whether the right things are attached?



On 6 Dec 2006, at 04:28, Chris Suter wrote:

I believe runMode:beforeDate can return immediately when there are no input sources.

I'll bet it's returning NO.

- Chris

On 06/12/2006, at 3:21 PM, Martin Redington wrote:


Please remind me never to do any multi-threaded programming again.

I have a loop that drives my worker thread, that looks something like the code below. Recently, I've observed one of these threads (occasionally more, but usually just one), "spinning" in this loop, and consuming a lot of CPU. I'm pretty certain that at the time, the thread is not receiving any messages, just waiting around to be reaped. Normally, this code runs without incident.

// threadRunning is a utility method that checks the threadDictionary to see if a flag has been set.
// it is only set or accessed from within the current thread.


while ([self threadRunning])
{
NSDate *newDate = [[NSDate alloc] initWithTimeIntervalSinceNow: 0.50];
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:newDate];
[newDate release];
}




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: thread spinning ...
      • From: Chris Suter <email@hidden>
References: 
 >thread spinning ... (From: Martin Redington <email@hidden>)
 >Re: thread spinning ... (From: Chris Suter <email@hidden>)

  • Prev by Date: Re: Framework for displaying Trees graphically?
  • Next by Date: Re: thread spinning ...
  • Previous by thread: Re: thread spinning ...
  • Next by thread: Re: thread spinning ...
  • Index(es):
    • Date
    • Thread