-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 9/29/11 10:50 PM, Greg Guerin wrote: > Gordon Apple wrote: > >> There must already be an array for the table, so just iterate >> the > array every >> minute or whatever (single repeating timer), compare the times to >> [NSDate date} and start or shut down whatever has not been >> started or shut > down. Much >> easier than trying to manage timers. > > You don't have to iterate the whole array, either. Sort it by > ascending order of turn-off time. Keep a current position (index). > If the time of day is less than the turn-off time of the device at > the current position, do nothing. If time of day >= turn-off time > of current position, then turn it off and advance position until > time of day is again less than the turn-off time of device at the > current position. Only needs one timer, and scales to as large an > array as you want to keep.
I don't really see how this is superior to keeping the one timer per remote box. When the user updates a timer, one is forced to re-sort the array and reposition the index (under the above implementation). One would also have to implement the scheme carefully, particularly if the shut-off code is offloaded onto separate threads, to avoid potential race conditions arising from a user changing a fire date in the middle of a shut-off sequence. And as Graham mentioned, polling is probably less CPU and power efficient than using timers anyway. Am I missing something conceptually here? Why are people pushing for the single timer model? Is there some hidden complexity in a multi-timer approach that I'm not seeing? - -- Conrad Shultz Synthetiq Solutions www.synthetiqsolutions.com -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk6FbZoACgkQaOlrz5+0JdUAuQCcC3cpCXFJSa7/AMJcrca7l749 1zcAn1tM1yHYuZkoZhvCMPVdAA1UBX4u =tv8r -----END PGP SIGNATURE----- _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com