• 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: Best way to push action from 1 thread to another?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to push action from 1 thread to another?


  • Subject: Re: Best way to push action from 1 thread to another?
  • From: Nathan Day <email@hidden>
  • Date: Sat, 11 May 2002 00:12:19 +0930

On Thursday, May 9, 2002, at 04:57 AM, Dave Fayram wrote:

Hi,
Well I ended up using notifications in my network monitor. So now I've got another "efficiency" question. I'm
currently using a thread to loop on a pcap socket, which then pushes the data pcap returns through an NSPort
to get it back into the thread that the AppKit NSRunLoop resides on. This works, but I'm curious if this is the
Best Way(tm) to go about pushing data from one thread to the next. I'm almost inclined to write a more efficient
pthreads solution personally. There is a lot of overhead with using the mach port to do it (and not just in using
the port, also in stuff like archiving the desired objects as data to send via the port)


So probably the best thing I can ask as a followup is, is there a way to send notifications such that
they occur in a different thread? Maybe some magical thing I'm overlooking? It would seem to me a lot
of developers would want this, since AppKit isn't thread safe...

I've written a class to do this, which is available on my iTools web site, it uses a port but only passes the a NSInvocation objects address and an NSLock's address if the caller wants to wait for a return object, it can do more than just notifications. I've thought about rewriting it to use a NSMachPort for more efficiency, don't have to create an NSData object and an NSArray just to pass two object addresses, but I haven't been in a situation where the efficiency was a problem and it wasn't immediately obvious how to use an NSMachPort, besides my main interest was in making it easier to use than DO.

http://homepage.mac.com/nathan_day/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Best way to push action from 1 thread to another? (From: Dave Fayram <email@hidden>)

  • Prev by Date: Re: NSPopUpButtons in an NSTableView
  • Next by Date: RE: [sort of OT] C++ headers and Objective-C++
  • Previous by thread: Re: Best way to push action from 1 thread to another?
  • Next by thread: Redirect the output of a *NIX log file
  • Index(es):
    • Date
    • Thread