>>> Anybody here using __event? Could you please discuss any potential
>>> issues with it other than portability?
[quoted text clipped - 6 lines]
> I was wondering about the native C++ part of it. Would you rather look
> into
You were in the C++/CLI newsgroup... microsoft.public.vc.language is focused
on native features.
> a third party library or would you consider using the __event, __hook
> and __unhook? Overall, I did not find any good feedback on the __event
> mechanism during my research, but I would defenitely want to use it
> if it's here to stay. I have done some tests of my own and tried out
> MSDN samples. It does exactly what I want it to do. Now I am
> looking for some reassurance.
Are you looking for COM compatibility? If you just want event handling in
within a C++ application, then pointer-to-member-function is 100% in the C++
standard and does what you want. In the rare case you need to support
multiple subscribers, then a std::vector or std::list of
pointer-to-member-function will get you there, again 100% standard and
portable. A template helper function can hide the details of iterating
through and calling all receivers. That will get even better in C++0x with
template support for arbitrary argument lists (not sure what the correct
name of the feature is).
> Priyesh
Boris - 02 Sep 2007 12:39 GMT
> [...]Are you looking for COM compatibility? If you just want event
> handling in within a C++ application, then pointer-to-member-function is
> 100% in the C++ standard and does what you want. In the rare case you
> need to support multiple subscribers, then a std::vector or std::list of
> pointer-to-member-function will get you there, again 100% standard and
> portable.
Or have a look at Boost.Signals (see
http://www.boost.org/doc/html/signals.html) which is
C++ standard-compatible library which should do what you want out of the
box.
Boris
PGP - 05 Sep 2007 18:19 GMT
>> [...]Are you looking for COM compatibility? If you just want event
>> handling in within a C++ application, then pointer-to-member-function is
[quoted text clipped - 8 lines]
>
> Boris
Boris,
Thanks for the suggestion. Boost looks excellent. I have contemplated on
using
Boost multiple times before and havent yet. Although starting to use Boost
now
will be a good idea as there are other excellent features like regex that i
could
take advantage of, it is too much of a change to introduce at this point to
otherwise
stable code so i am a little worried.
Priyesh
PGP - 05 Sep 2007 18:14 GMT
>>>> Anybody here using __event? Could you please discuss any potential
>>>> issues with it other than portability?
[quoted text clipped - 28 lines]
>
>> Priyesh
Ben,
COM is not in the picture. I am also not worried about porting this code
outside MS compilers. Calling multiple subscribers is a needed feature.
__hook supports calling multiple subscribers and it's thread safe. Apart
from potential portability issues, it seems to me that __hook is a perfect
fit.
If i roll my own as you suggest, i am still left with the task of
synchronizing
access from multiple threads.
Priyesh