rpc_ss_get_thread_handle(3rpc) — Subroutines
NAME
rpc_ss_get_thread_handle — Gets a thread handle for the manager code before it spawns additional threads, or for the client code when it becomes a server; used by server or possibly by client applications
Synopsis
rpc_ss_thread_handle_t rpc_ss_get_thread_handle(
void);
Description
The rpc_ss_get_thread_handle() routine is used by a server manager thread when it spawns additional threads. To spawn additional threads that are able to perform memory management, the server manager code calls rpc_ss_get_thread_handle() and passes the thread handle to each spawned thread. Each spawned thread that uses rpc_ss_allocate() and rpc_ss_free() for memory management must first call rpc_ss_set_thread_handle(), using the handle obtained by the original manager thread.
The rpc_ss_get_thread_handle() routine can also be used when a program changes from being a client to being a server. The program gets a handle on its environment as a client by calling rpc_ss_get_thread_handle(). When the program reverts to being a client it re−establishes the client environment by calling rpc_ss_set_thread_handle(), supplying the previously obtained handle as a parameter.
Return Values
A thread handle.
Examples
This function determines the thread handle, creates a thread, and passes the thread handle to the thread so it can share the memory management environment of the calling thread.
#include <pthread.h>
#include <idlbase.h>
pthread_t Launch_thread(
int (∗routine_to_launch)(
pthread_addr_t th
)
)
{
rpc_ss_thread_handle_t th = rpc_ss_get_thread_handle();
pthread_t t;
/∗
∗ Create the thread and pass to it the thread handle
∗ so it can use rpc_ss_set_thread_handle.
∗/
pthread_create (&t, pthread_attr_default,
(pthread_startroutine_t)routine_to_launch,
(pthread_addr_t)th);
return t;
}
Errors
A representative list of errors that might be returned is not shown here. Refer to the OSF DCE Problem Determination Guide for complete descriptions of all error messages.
Related Information
Functions: rpc_ss_allocate(3rpc), rpc_ss_free(3rpc), rpc_ss_set_thread_handle(3rpc).