|
Boost : |
From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2000-11-16 17:55:07
> 1. Need to allow traditional functor types as the callback so that
> function pointers, standard functors, hand coded functors and Lambda
> Library style functors can all be used with relative ease.
Yes, this style was used in the ScopeGuard, and it works
well with Lambda functors, and std binders.
> 2. The callback type(s) should be templatized on the return type and
> argument types, but not on the functor type to simplify useage.
There may be issues with partial declaration of the functor, but in general
it makes using one very easy.
> 3. Copying a callback should be quick, on par with copying a
> function pointer. This is not gauranteed with functors but becomes
> somewhat important with callbacks that may be stored, copied and
> passed around frequently in some cases.
If the callback is a "base pointer" to a callback this should be trivial.
The Janitor class that is in ScopeGuard does this using an auto_ptr<>.
> 4. A callback should itself be a functor.
This falls out of requirement #2.
> 5. Compiler type coercion should be possible to apply to the functor
> that the callback wraps for all parameters and the return value.
The lambda library has such tools. (Peter's version does too.) We recently
added the 4 std casts as well.
> 6. Executing a callback should be nearly as efficient as executing
> the contained functor.
This is also very compiler dependent. But in general should be a pointer
deference, and then the function call.
> (I'm chewing on several Boost related things right now, so if there's
> someone else interested in tackling this I'd prefer it. If there
> isn't then I'll have to tackle it, because this is going to be a
> fundamental requirement for threads.)
>
If there is any support that LL could provide to make this easier I'm
willing to help out. Jaakko and I are dealing with some of these issues
right now.
-gary-
gary.powell_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk