site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:content-transfer-encoding:mime-version:subject:date :x-mailer; bh=Cs9kzSqMUCaVlkBh+K81Fwb1sawaWFAujGbMLA9odEw=; b=x0qK1IS0/b16N1GYa16alxjqkjYKQ4nYEOwFcK8kO+Fn7efiWeqoXO2l10O+yk5nFa 5Lb2rFzEGYRNakbFzZvKQ8bitQJ0kNcY4Mn9/rDUCzGXhd9Vu75gXdGD+555pD5z2Slp J+xzvzqwXXtoiKBnk6io0u9PkHzXtU3DFVsQk= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:content-transfer-encoding :mime-version:subject:date:x-mailer; b=Uw09feROU0dZdUk8GGhWPdLPstIy9wpSIHvIdbbJXa6RXmMlLAujkoaGAeh6MmT49C L5UailDdM9UloVo4nN5LeKasDE/e8Oqu/SBMCoUne91wc0eQLfeoi0N/JtqDgARiuqqV DzBoKm0WS7SPAGPGxviSUvLsDf8pHdzD0jATs= Which is the best design and how efficient? Thanks in advance, Joel --- http://tinyco.de --- Mac & iPhone _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... Suppose I'm trying to create a very efficient network server. I define efficiency as low latency and low CPU usage. The server is to run on the iPhone. The server will use one ring buffer each for sending and receiving data. I don't think it matters whether it's TCP or UDP for the purpose of this discussion. A producer is pumping out packets at high speed and there a main GUI thread with a run loop. One design would involve adding a CFSocket per connection to the run loop and using a separate thread and a semaphore to notify the network server that there's data to be broadcast to clients. I'm not sure if each CFSocket creates a separate thread or there's a thread managing all of them together. Not sure if it matters. There are at least two threads in this design and separate threads for network sending and receiving. Another design could use a pipe to wake up the network server and add it to the list of native sockets monitored by the server. This design could use either select or kqueue/kevent and may not need CFSocket. Sending and receiving here would run in a single thread since the pipe is just another descriptor to be monitored. How efficient is it to put a byte into a pipe in a callback that gets triggered every few milliseconds? Would there be a significant gain since an extra thread is not required to wait on a semaphore? Would it even out since (intuitively) a pipe is slower? This email sent to site_archiver@lists.apple.com