Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

ctThrdMutexInit

Initialize memory for a mutex.

Short Name

ctThrdMutexInit()

Type

Threading function

Declaration

NINT ctThrdMutexInit(pctMUTEX mutex)

Description

ctThrdMutexInit() provides a means to initialize mutex. Before using a mutex the memory for the mutex must be cleared. If this space is initialized when allocated, this function is not needed, for example, internally within the FairCom DB code.

However, if the mutex memory requires “zeroing out”, this function provides a convenient way to perform this task. This is most common when a mutex is defined on the stack within an application. In essence, this function simply initializes (memset()) the memory.

Return

ctThrdMutexInit() always returns NO_ERROR. See FairCom DB Error Codes for a complete listing of valid FairCom DB error values.

Example

NINT err; /* ctThrdInit return code. */

ctBLOCK guiblk; /* Block to wait for window creation. */

ctMUTEX tfin_mtx; /* Mutex for thread finished counter. */


#if (defined(USE_CURSES) || defined(USE_ANSI))

ctMUTEX tprt_mtx; /* Mutex for displaying thread output.*/

#endif /* USE_CURSES || USE_ANSI */


if ((err = ctThrdInit(3,(LONG) 0, (pctINIT)&cfg))) {

ctrt_printf("\nctThrdInit failed. Error={%d}\n", err);

ctrt_exit(1);

}


/* Initialize Blocks and Mutexes. */

ctThrdBlockInit(&guiblk);

ctThrdMutexInit(&tfin_mtx);

#if (defined(USE_CURSES) || defined(USE_ANSI))

ctThrdMutexInit(&tprt_mtx);

#endif /* USE_CURSES || USE_ANSI */

See also

ctThrdBlockInit

TOCIndex