RTI Connext C API  Version 5.3.1
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
DDS_ThreadFactory Struct Reference

<<extension>> <<interface>> Interface for providing the threads needed by the middleware. More...

Data Fields

void * factory_data
 A place for interface implementors to keep a pointer to data that may be needed by their factory.
 
DDS_ThreadFactory_CreateThreadCallback create_thread
 Handles the creation of new threads.
 
DDS_ThreadFactory_DeleteThreadCallback delete_thread
 Handles the deletion of threads previously created by this factory.
 

Detailed Description

<<extension>> <<interface>> Interface for providing the threads needed by the middleware.

It consists of operations to create and delete threads. The interface depends on the DDS_ThreadFactory_OnSpawnedFunction that specifies the operation to run in the new thread.

Field Documentation

void* DDS_ThreadFactory::factory_data

A place for interface implementors to keep a pointer to data that may be needed by their factory.

DDS_ThreadFactory_CreateThreadCallback DDS_ThreadFactory::create_thread

Handles the creation of new threads.

This callback is called by the middleware whenever it needs to create a new thread. The operation creates a new thread of control that will call the function specified by DDS_ThreadFactory_OnSpawnedFunction. On success, this operation must guarantee that after return the new thread of control been spawned and its execution has started or will start some time after.

The DDS_ThreadFactory_OnSpawnedFunction, function must be called in the new thread and return its value on finalization. The function should be called as follows:

void * thread_out = on_spawned(thread_params);
...
return thread_out;

Some thread frameworks do this directly by just receiving the function and its parameters as arguments on thread creation. For instance, POSIX follows this model when creating a thread and the start_routine function has the same signature as DDS_ThreadFactory_OnSpawnedFunction, so the parameter can be passed directly:

int result = pthread_create(&pthread_handle, &attr, on_spawned, thread_params);
...
return &pthread_handle;
DDS_ThreadFactory_DeleteThreadCallback DDS_ThreadFactory::delete_thread

Handles the deletion of threads previously created by this factory.

This callback is called by the middleware whenever it needs to delete a thread. This operation deletes a thread previously created via a call to DDS_ThreadFactory::create_thread on the same factory object. On success, the thread must be deleted but it does not have to guarantee that the execution has finished. Likewise, resources associated with the underlying operating system may be still in use. Depending on the thread framework, resources allocated on thread creation are released upon thread finalization. POSIX follows this model so no actions are required on the thread handle returned by pthread_create().


RTI Connext C API Version 5.3.1 Copyright © Mon Feb 19 2018 Real-Time Innovations, Inc