FairCom Corporation


F.52 ctThrdBlockInit


Initialize memory for a thread block.

Short Name

ctThrdBlockInit

TYPE

Threading Function

DECLARATION

NINT ctThrdBlockInit(pctBLOCK block)

DESCRIPTION

ctThrdBlockInit provides a means to initialize block. Before using a block the memory for the block must be cleared. If this space is initialized when allocated, this function is not needed.

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

RETURN

ctThrdBlockInit always returns NO_ERROR. See Appendix A "c-tree Plus Error Codes" of the c-tree Plus Programmer's Reference Guide for a complete listing of valid c-tree Plus 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

ctThrdMutexInit


FairCom Corporation
www.faircom.com