Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

ctThrdInit

Initialize thread management.

Short Name

ctThrdInit()

Type

Threading function

Declaration

NINT ctThrdInit(NINT numthreads, LONG mode, pctINIT cfg)

Description

ctThrdInit() initializes FairCom DB thread management. When using a multithreaded FairCom DB library, you must call ctThrdInit() before initializing FairCom DB.

mode is either zero or ctThrdFIXED_THREADS. In ctThrdFIXED_THREADS mode numthreads represents the fixed maximum number of threads available at one time. Otherwise, numthreads simply represents the number of threads allocated each time new threads are required.

cfg should be NULL for non-server applications. In the Bound Server Model, cfg points to a parameter block representing the FairCom Server configuration file options. If cfg is NULL, the bound FairCom Server, i.e., Custom Server, is initialized similarly to a standard FairCom Server.

Checking if ctThrdInit() Has Been Called

(In V11.5 and later) In the server, multi-threaded client, and multi-threaded standalone c-tree operational models, it is possible to determine if ctThrdInit() has already been called by calling ctThrdInit() as follows:

NINT rc;

rc = ctThrdInit(0,ctThrdCHECK_INIT,NULL);

When a mode of ctThrdCHECK_INIT is specified, ctThrdInit() returns a value of YES if a successful ctThrdInit() call has already been made and returns NO otherwise. In both cases it does not perform any initialization.

Failed Calls

With the c-tree database engine DLL model, a failed ctThrdInit() call due to insufficient memory resulted in exiting the process in prior releases. In this release and later, it is possible for an application to take its own actions when ctThrdInit() fails. When the database engine shutdown function is called due to an error occurring during a ctThrdInit() call, the function will return instead of exiting the process. The error code is returned to the caller.

Return

Value

Symbolic Constant

Explanation

0

NO_ERROR

Successful thread initialization.

82

UALC_ERR

Could not allocate memory.

See FairCom DB Error Codes for a complete listing of valid FairCom DB error values.

Example

COUNT retval2;

NINT retval4;


if (retval4 = ctThrdInit(5, NULL, NULL)) {

ctThrdTerm();

return(retval4);

}

if ((retval2 = InitISAM(6, 25, 32)) {

CloseISAM();

return((NINT) retval2);

}

dbWork();

CloseISAM();

ctThrdTerm();

return(0)

Limitations

Required with a ctThrd library.

See also

ctThrdTerm

TOCIndex