Add wxThreadEvent::SetPayload<T>().

This makes it possible to easily pass custom data between threads, in
type-safe way (thanks to internal use of wxAny). This adds
sizeof(wxAny)==16+sizeof(void*) overhead to wxThreadEvent, but I think
it's cheaper than doing malloc/free on copying.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63187 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2010-01-19 13:01:40 +00:00
parent f8a7dd5f41
commit dae60aeebb
2 changed files with 53 additions and 0 deletions

View File

@@ -2853,6 +2853,37 @@ public:
when calling wxEventLoopBase::YieldFor().
*/
virtual wxEventCategory GetEventCategory() const;
/**
Sets custom data payload.
The @a payload argument may be of any type that wxAny can handle
(i.e. pretty much anything). Note that T's copy constructor must be
thread-safe, i.e. create a copy that doesn't share anything with
the original (see Clone()).
@note This method is not available with Visual C++ 6.
@since 2.9.1
@see GetPayload(), wxAny
*/
template<typename T>
void SetPayload(const T& payload);
/**
Get custom data payload.
Correct type is checked in debug builds.
@note This method is not available with Visual C++ 6.
@since 2.9.1
@see SetPayload(), wxAny
*/
template<typename T>
T GetPayload() const;
};