F.65 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 c-tree Plus 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 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
ctThrdBlockInit
|
FairCom Corporation www.faircom.com |