Thursday, August 7, 2008

Identifiers

Hello,

It is sometimes necessary to identify objects in a system. In my audio system particularily, some objects broadcast messages concerning some event, and receivers of these messages must identify the source. When writing a single process, non-persistant application, a logical choice for an identifier would be the memory address at which the object resides. This can be beneficial if we want to identify and then access a broadcaster, as turning it's identifier into a usable handle requires no lookup tables. However, I want my framework to support, multiprocess, multimachine application designs, and I want my objects to support persistence. I also want to have quick easy access to broadcaster objects whenever possible.

How do I do this? Well, an obvious solution is to embed an address space identifier, and an object pointer in an identifier. When a receiver gets a broadcasted message, it can check to see if it is from an object in the same address space, and if so, quickly get a pointer from the object identifier, using a cast. If however, the address space identifier does not match ours, then we take the usual lookup table route to get a local proxy object. Thats it.

1 comment:

Nick.Moo said...

hey guy, thank you for this, its inspiring, im thinking of writing some audio units myself, and i love mac and obj-c... please continue - i totally appreciate your blogging :)