VMS Help  —  DCE  DCE_RPC, Application Routines, rpc_ss_get_thread_handle
 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

   #include <dce/rpc.h>

   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;
        }

 RELATED INFORMATION

   Functions:  rpc_ss_allocate
               rpc_ss_free
               rpc_ss_set_thread_handle
Close Help