Kanbaru 🌟 (one hikari of too many)

it extremely annoys me that you can have event-driven systems where you trigger an event and set up the event handler after the fact, hoping the event hasn’t actually happened yet

yes multiple early iPhone OS apps do this, why do you ask,

1 replies →
1 replies

Saagar Jha

(replying to Kanbaru 🌟 (one hikari of too many))
@hikari …in the same runloop iteration, or a subsequent one?

Kanbaru 🌟 (one hikari of too many)

(replying to Saagar Jha)

@saagar same runloop iteration… usually. ah, are you going to tell me there’s some guarantee about this? :)

1 replies →
1 replies

Saagar Jha

(replying to Kanbaru 🌟 (one hikari of too many))
@hikari I would definitely not write code relying on this but I would expect events to be queued for dispatch on the next iteration of the runloop

Kanbaru 🌟 (one hikari of too many)

(replying to Kanbaru 🌟 (one hikari of too many))

@saagar something I’m not sure about is how NSNotificationCenter interacts with run loops.

2 replies →
2 replies

Saagar Jha

(replying to Kanbaru 🌟 (one hikari of too many))
@hikari I haven’t looked at this closely but I think the default is enqueuing but IIRC NSNotificationQueue lets you bypass that

Kanbaru 🌟 (one hikari of too many)

(replying to Saagar Jha)

@saagar ahh okay. touchHLE currently has an ad-hoc notification queue inside the “movie player”, simply because it never worked when I posted the notification immediately, but maybe I actually should put that queueing inside NSNotificationCenter itself…


al45tair

(replying to Kanbaru 🌟 (one hikari of too many))
@hikari @saagar NSNotificationCenter delivers notifications immediately, on the thread they’re sent on. (NSDistributedNotificationCenter is obviously different.)

Saagar Jha

(replying to al45tair)
@al45tair @hikari ^ you should generally trust the Cocoa veterans rather than me on this

Kanbaru 🌟 (one hikari of too many)

(replying to Kanbaru 🌟 (one hikari of too many))

my modest proposal is that such systems should check if appropriate event handlers are registered before you do something that can produce an event, and if they aren’t, refuse to deliver the event later, even if handlers were set up in the meantime 😈