---
name: "ACE_Thread_Adapter"
section: "3"
platform: "linux"
package: "libace-doc"
version: "5.0.7-4"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/ACE_Thread_Adapter"
---

# ACE\_Thread\_Adapter(3)

Converts a C++ function into a function ace\_thread\_adapter 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.

## NAME

ACE\_Thread\_Adapter -  Converts a C++ function into a function ace\_thread\_adapter 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.

## SYNOPSIS

```
#include <ace/OS.h>
class ACE_Thread_Adapter
{
  public:
    ACE_Thread_Adapter (
        ACE_THR_FUNC user_func,
        void *arg,
        ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ace_thread_adapter,
        ACE_Thread_Manager *thr_mgr = 0,
        ACE_Thread_Descriptor *td = 0 ,
        ACE_SEH_EXCEPT_HANDLER selector = 0,
        ACE_SEH_EXCEPT_HANDLER handler = 0
        );
    void *invoke (void);
    ACE_Thread_Manager *thr_mgr (void);
    ACE_THR_C_FUNC entry_point (void);
  private:
    ~ACE_Thread_Adapter (void);
    void inherit_log_msg (void);
    ACE_THR_FUNC user_func_;
    void *arg_;
    ACE_THR_C_FUNC entry_point_;
    ACE_Thread_Manager *thr_mgr_;
    ACE_OS_Thread_Descriptor *thr_desc_;
    ACE_OSTREAM_TYPE *ostream_;
    u_long priority_mask_;
    int tracing_enabled_;
    int restart_;
    int trace_depth_;
    ACE_SEH_EXCEPT_HANDLER seh_except_selector_;
    ACE_SEH_EXCEPT_HANDLER seh_except_handler_;
    friend class ACE_Thread_Adapter_Has_Private_Destructor;
};
```

## DESCRIPTION

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 invoke on this object.  Therefore, the invoke method is responsible for deleting itself.

## PUBLIC MEMBERS

```
ACE_Thread_Adapter (
    ACE_THR_FUNC user_func,
    void *arg,
    ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ace_thread_adapter,
    ACE_Thread_Manager *thr_mgr = 0,
    ACE_Thread_Descriptor *td = 0 ,
    ACE_SEH_EXCEPT_HANDLER selector = 0,
    ACE_SEH_EXCEPT_HANDLER handler = 0
    );
```

Constructor.

```
void *invoke (void);
```

Execute the user\_func\_ with the arg.  This function deletes this, thereby rendering the object useless after the call returns.

```
ACE_Thread_Manager *thr_mgr (void);
```

Accessor for the optional Thread\_Manager.

```
ACE_THR_C_FUNC entry_point (void);
```

Accessor for the C entry point function to the OS thread creation routine.

## PRIVATE MEMBERS

```
~ACE_Thread_Adapter (void);
```

Ensure that this object must be allocated on the heap.

```
void inherit_log_msg (void);
```

Inherit the logging features if the parent thread has an ACE\_Log\_Msg.

```
ACE_THR_FUNC user_func_;
```

Thread startup function passed in by the user (C++ linkage).

```
void *arg_;
```

Argument to thread startup function.

```
ACE_THR_C_FUNC entry_point_;
```

Entry point to the underlying OS thread creation call (C linkage).

```
ACE_Thread_Manager *thr_mgr_;
```

Optional thread manager.

```
ACE_OS_Thread_Descriptor *thr_desc_;
```

Optional thread descriptor.  Passing this pointer in will force the spawned thread to cache this location in Log\_Msg and wait until Thread\_Manager fills in all information in thread descriptor.

```
ACE_OSTREAM_TYPE *ostream_;
```

Ostream where the new TSS Log\_Msg will use.

```
u_long priority_mask_;
```

Priority\_mask to be used in new TSS Log\_Msg.

```
int tracing_enabled_;
```

Are we allowing tracing in this thread?

```
int restart_;
```

Indicates whether we should restart system calls that are interrupted.

```
int trace_depth_;
```

Depth of the nesting for printing traces.

```
ACE_SEH_EXCEPT_HANDLER seh_except_selector_;
```

```
ACE_SEH_EXCEPT_HANDLER seh_except_handler_;
```

```
friend class ACE_Thread_Adapter_Has_Private_Destructor;
```

Friend declaration to avoid compiler warning:  only defines a private destructor and has no friends.

## AUTHOR

Doug Schmidt schmidt@cs.wustl.edu, Jesper S. M\|ller stophph@diku.dk, and a cast of thousands...

## The ACE\_Sched\_Priority type should be used for platform-

independent thread and process priorities, by convention. int should be used for OS-specific priorities.

## typedef for the \_stat data structure

## Giving unique ACE scoped names for some important

RTSignal-Related constants. Becuase sometimes, different platforms use different names for these constants.

## LIBRARY

ace
