Files
TCPlayerbotCore/dep/ACE_wrappers/ace/Thread_Adapter.h
T

102 lines
2.8 KiB
C++
Raw Normal View History

// -*- C++ -*-
2009-10-17 15:51:44 -07:00
//=============================================================================
/**
* @file Thread_Adapter.h
*
* $Id: Thread_Adapter.h 80826 2008-03-04 14:51:23Z wotte $
*
* @author Carlos O'Ryan <[email protected]>
*/
//=============================================================================
2009-10-17 15:51:44 -07:00
#ifndef ACE_THREAD_ADAPTER_H
#define ACE_THREAD_ADAPTER_H
#include /**/ "ace/pre.h"
2009-10-17 15:51:44 -07:00
#include /**/ "ace/ACE_export.h"
2009-10-17 15:51:44 -07:00
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
2009-10-17 15:51:44 -07:00
#include "ace/Base_Thread_Adapter.h"
2009-10-17 15:51:44 -07:00
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
2009-10-17 15:51:44 -07:00
// Forward decl.
class ACE_Thread_Manager;
class ACE_Thread_Descriptor;
2009-10-17 15:51:44 -07:00
/**
* @class ACE_Thread_Adapter
*
* @brief Converts a C++ function into a function that
* can be called from a thread creation routine
* (e.g., pthread_create() or _beginthreadex()) that expects an
* extern "C" entry point. This class also makes it possible to
* transparently provide hooks to register a thread with an
* ACE_Thread_Manager.
*
* This class is used in ACE_OS::thr_create(). In general, the
* thread that creates an object of this class is different from
* the thread that calls @c invoke() on this object. Therefore,
* the @c invoke() method is responsible for deleting itself.
*/
class ACE_Export ACE_Thread_Adapter : public ACE_Base_Thread_Adapter
{
public:
/// Constructor.
ACE_Thread_Adapter (ACE_THR_FUNC user_func,
void *arg,
ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME,
ACE_Thread_Manager *thr_mgr = 0,
ACE_Thread_Descriptor *td = 0
# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
, ACE_SEH_EXCEPT_HANDLER selector = 0,
ACE_SEH_EXCEPT_HANDLER handler = 0
# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
);
2009-10-17 15:51:44 -07:00
/**
* Execute the <user_func_> with the <arg>. This function deletes
* @c this, thereby rendering the object useless after the call
* returns.
*/
virtual ACE_THR_FUNC_RETURN invoke (void);
2009-10-17 15:51:44 -07:00
/// Accessor for the optional ACE_Thread_Manager.
ACE_Thread_Manager *thr_mgr (void);
2009-10-17 15:51:44 -07:00
protected:
2009-10-17 15:51:44 -07:00
/// Ensure that this object must be allocated on the heap.
~ACE_Thread_Adapter (void);
2009-10-17 15:51:44 -07:00
private:
2009-10-17 15:51:44 -07:00
/// Called by invoke, mainly here to separate the SEH stuff because
/// SEH on Win32 doesn't compile with local vars with destructors.
virtual ACE_THR_FUNC_RETURN invoke_i (void);
2009-10-17 15:51:44 -07:00
private:
2009-10-17 15:51:44 -07:00
/// Optional thread manager.
ACE_Thread_Manager *thr_mgr_;
2009-10-17 15:51:44 -07:00
};
2009-10-17 15:51:44 -07:00
ACE_END_VERSIONED_NAMESPACE_DECL
2009-10-17 15:51:44 -07:00
# if defined (ACE_HAS_INLINED_OSCALLS)
# if defined (ACE_INLINE)
# undef ACE_INLINE
# endif /* ACE_INLINE */
# define ACE_INLINE inline
# include "ace/Thread_Adapter.inl"
# endif /* ACE_HAS_INLINED_OSCALLS */
2009-10-17 15:51:44 -07:00
#include /**/ "ace/post.h"
#endif /* ACE_THREAD_ADAPTER_H */
2009-02-17 20:07:49 -06:00