Daylight v4.9
Release Date: 1 February 2008

Name

dt_mp_initialize - initialize the toolkit for multithreading

Generic Prototype

dt_mp_initialize(dt_Integer) => dt_Boolean

C Prototype

#include "dt_smiles.h"

dt_Boolean dt_mp_initialize(dt_Integer flag)

FORTRAN Prototype

include 'dt_f_smiles.inc'

logical dt_f_mp_initialize(flag)

integer*4 flag

Description

This function sets up internal data structures within the toolkit to support pthread-based multithreading. It is not necessary to call this function for simple single-threaded toolkit programs or multi-threaded programs which only access the Daylight Toolkit through one thread in the program at a time; it is only necessary if there will be multiple threads accessing objects within the toolkit at the same time. The function must be called before any other toolkit functions within a program.

The 'flag' parameter controls the scope of handles within the toolkit; the value DX_MP_GLOBAL_HANDLES indicates that handles will be accessible to all threads within the program. The value DX_MP_PER_THREAD indicates that handles will only be accessible within the thread that creates the object. There is no way to change the scope of objects within a multi-threading program once the first object has been allocated; the mode chosen in dt_mp_initialize(3) is retained through execution of the program.

There is a slight performance penalty (10%) if one uses global handles since the internal toolkit must manage shared access to additional internal data structures. It is best not to share objects across threads if the program design allows it. If global handles are required, the functions dt_mp_lock(3), dt_mp_unlock(3), and dt_mp_trylock(3) are provided so the programmer can coordinate access of the objects.

Return Value

Returns FALSE if there is an error, TRUE otherwise.

Related Topics

dt_ancestor(3) dt_mp_lock(3) dt_mp_trylock(3) dt_mp_unlock(3)