• 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: POSIX sockets and event loops
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: POSIX sockets and event loops


  • Subject: Re: POSIX sockets and event loops
  • From: Eric Schlegel <email@hidden>
  • Date: Thu, 20 May 2004 16:23:37 -0700

On May 20, 2004, at 1:57 PM, Aaron Ballman wrote:

As much as I hate to admit this: we have an event loop that's using WaitNextEvent. When sockets are active, we pause for as little time possible (pass in 0 to WaitNextEvent), yet I am still finding that about 15% of my application's time is being spent in that one call. I am determining this by using Shark FWIW.

Because my application uses select to poll the socket for sends and receives, this sort of a hiccup in the application's event loop seems to slow my transfers down more than I care for.

Aside from the obvious (but quite difficult) answer of: stop using WaitNextEvent and use Carbon events everywhere... is there a way to cause WaitNextEvent to wake up when network I/O is occurring? For example, if I were to use signals instead of select, would the signals cause WaitNextEvent to not delay so long?

You can make WaitNextEvent wake up by calling WakeUpProcess. That API is not documented to be signal-safe, so I wouldn't advise calling it from within a signal handler; but you could do something like have a separate thread blocked on a semaphore, trigger the semaphore from your signal handler, and then call WakeUpProcess from that other thread.

Or, probably simpler, you could just call select() from a secondary thread to start with, and pass a large sleep value to WaitNextEvent, and then you wouldn't have to worry about WNE interfering with select at all.

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


References: 
 >POSIX sockets and event loops (From: Aaron Ballman <email@hidden>)

  • Prev by Date: Re: POSIX sockets and event loops
  • Next by Date: Re: POSIX sockets and event loops
  • Previous by thread: Re: POSIX sockets and event loops
  • Next by thread: gethostname
  • Index(es):
    • Date
    • Thread