---
name: "ACE_Thread_Descriptor"
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_Descriptor"
---

# ACE\_Thread\_Descriptor(3)

Information for controlling threads that run under the control of the Thread\_Manager.

## NAME

ACE\_Thread\_Descriptor -  Information for controlling threads that run under the control of the Thread\_Manager.

## SYNOPSIS

```
#include <ace/Thread_Manager.h>
class ACE_Thread_Descriptor : public ACE_Thread_Descriptor_Base
{
  public:
    friend class ACE_At_Thread_Exit;
    friend class ACE_Thread_Manager;
    friend class ACE_Double_Linked_List<ACE_Thread_Descriptor>;
        friend class ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor>;

    ACE_Thread_Descriptor (void);
    ACE_thread_t self (void);
    void self (ACE_hthread_t &);
    void dump (void) const;
    void log_msg_cleanup(ACE_Log_Msg* log_msg);
    int at_exit (ACE_At_Thread_Exit* cleanup);
    int at_exit (ACE_At_Thread_Exit& cleanup);
    int at_exit (
        void *object,
        ACE_CLEANUP_FUNC cleanup_hook,
        void *param
        );
    ~ACE_Thread_Descriptor (void);
    void acquire_release (void);
    ACE_INLINE_FOR_GNUC void set_next (ACE_Thread_Descriptor *td);
    ACE_INLINE_FOR_GNUC ACE_Thread_Descriptor *get_next (void);
  private:
    void at_pop (int apply = 1);
    void at_push (ACE_At_Thread_Exit* cleanup, int is_owner = 0);
    void do_at_exit (void);
    void terminate (void);
    ACE_Log_Msg *log_msg_;
    ACE_At_Thread_Exit *at_exit_list_;
    ACE_Cleanup_Info cleanup_info_;
    ACE_Thread_Manager* tm_;
    ACE_DEFAULT_THREAD_MANAGER_LOCK *sync_;
    int terminated_;
};
```

## Initialization method.

```
ACE_Thread_Descriptor (void);
```

## Accessor methods.

```
ACE_thread_t self (void);
```

Unique thread id.

```
void self (ACE_hthread_t &);
```

Unique handle to thread (used by Win32 and AIX).

```
void dump (void) const;
```

Dump the state of an object.

```
void log_msg_cleanup(ACE_Log_Msg* log_msg);
```

This cleanup function must be called only for ACE\_TSS\_cleanup. The ACE\_TSS\_cleanup delegate Log\_Msg instance destruction when Log\_Msg cleanup is called before terminate.

```
int at_exit (ACE_At_Thread_Exit* cleanup);
```

Register an At\_Thread\_Exit hook and the ownership is acquire by Thread\_Descriptor, this is the usual case when the AT is dynamically allocated.

```
int at_exit (ACE_At_Thread_Exit& cleanup);
```

Register an At\_Thread\_Exit hook and the ownership is retained for the caller. Normally used when the at\_exit hook is created in stack.

```
int at_exit (
    void *object,
    ACE_CLEANUP_FUNC cleanup_hook,
    void *param
    );
```

Register an object (or array) for cleanup at thread termination. "cleanup\_hook" points to a (global, or static member) function that is called for the object or array when it to be destroyed. It may perform any necessary cleanup specific for that object or its class.  "param" is passed as the second parameter to the "cleanup\_hook" function; the first parameter is the object (or array) to be destroyed.  Returns 0 on success, non-zero on failure: -1 if virtual memory is exhausted or 1 if the object (or arrayt) had already been registered.

```
~ACE_Thread_Descriptor (void);
```

Do nothing destructor to keep some compilers happy

```
void acquire_release (void);
```

Do nothing but to acquire the thread descriptor's lock and release.  This will first check if the thread is registered or not.  If it is already registered, there's no need to reacquire the lock again.  This is used mainly to get newly spawned thread in synch with thread manager and prevent it from accessing its thread descriptor before it gets fully built.  This function is only called from ACE\_Log\_Msg::thr\_desc.

```
ACE_INLINE_FOR_GNUC void set_next (ACE_Thread_Descriptor *td);
```

```
ACE_INLINE_FOR_GNUC ACE_Thread_Descriptor *get_next (void);
```

Set/get the next\_ pointer.  These are required by the ACE\_Free\_List.  ACE\_INLINE is specified here because one version of g++ couldn't grok this code without it.

## AUTHOR

Doug Schmidt

## LIBRARY

ace
