Am 13.07.2006 um 22:16 schrieb Stephen Deasey:


Why can't you initialise resources when you register the callback?  I
don't think I understand the problem here...

Well, my first idea was to get a kind of "self-initializing" and
"self-cleaning" procedures. Most importantly the "self-cleaning"
as "self-initializing" is pretty easy to make with kind-of
"static" variables.

So I *can* check if the callback is called for the first time
but I *do not* know when it is called for the last time!
Knowing when I'm called for the first time allows me to build
the internal cache, and knowing when I'm called the last time
allows me to cleanup. This way the initialization and cleanup
are inherent for the callback procedure and nothing else is
needed from the outside to make it happen.

But...

After thinking more and more, I see that we can't simply
generalize that to be backward compatible. And if we can't
do that, then we'd had pretty inelegant solution. Therefore
I will step back and do as you suggested: before I register
the callback I will manually initialize it, and after I
unregister I will manually invoke the cleanup.

I just though this can be somehow simplified but must admit
that this is not simple, given the code we already have.

So, consider this idea trashed. Sorry for the noise...

Cheers
Zoran

Reply via email to