Back to home page

Enduro/X

 
 

    


0001 TPSETCTXT(3)
0002 ============
0003 :doctype: manpage
0004 
0005 
0006 NAME
0007 ----
0008 tpsetctxt - Set thread context data (thread local storage data)
0009 
0010 
0011 SYNOPSIS
0012 --------
0013 #include <atmi.h>
0014 
0015 int tpsetctxt(TPCONTEXT_T 'context', long 'flags');
0016 
0017 Link with '-latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lubf -lnstd -lpthread -lrt -lm'
0018 
0019 DESCRIPTION
0020 -----------
0021 This function is used to set context data which previously was returned by 
0022 *tpgetctxt(3)* funcion. If previous thread was associated with XA global 
0023 transaction, then it will be resumed at this thread. 'context' parameter 
0024 accepts either thread context returned by *tpgetctxt()* or *TPNULLCONTEXT*. 
0025 *TPNULLCONTEXT* will enter the current thread in NULL context and will free 
0026 up the currently associated automatically allocated thread local storage (TLS). 
0027 Automatically allocated TLS is one which is not made by *tpnewctxt(3)* but 
0028 created implicitly by ATMI any other ATMI operation which requires context.
0029 
0030 If current thread was running in some context, it will be terminated 
0031 (with *tpterm(3)*), TLS data will be freed. And new context will be installed.
0032 
0033 This function uses underlaying thread local storage infrastructure which is 
0034 provided separately for each of the major Enduro/X libraries - libnstd 
0035 (Standard library), libufb (UBF buffer library) and libatmi (ATMI library). 
0036 If operations at library levels are required, then following functions can be used:
0037 
0038 1. ndrx_nstd_tls_new(), ndrx_ubf_tls_new(), ndrx_atmi_tls_new() - 
0039 allocate TLS data for library.
0040 
0041 2. ndrx_nstd_tls_get(), ndrx_ubf_tls_get(), ndrx_atmi_tls_get() - get the TLS 
0042 data for library (currently associated with thread).
0043 
0044 3. ndrx_nstd_tls_set(), ndrx_ubf_tls_set(), ndrx_atmi_tls_set() - set the thread
0045 local data from saved pointer.
0046 
0047 4. ndrx_nstd_tls_free(), ndrx_ubf_tls_free(), ndrx_atmi_tls_free() - free the 
0048 thread local data.
0049 
0050 
0051 RETURN VALUE
0052 ------------
0053 On success, *tpsetctxt()* return 0; on error, -1 is returned, with
0054 *tperrno* set to indicate the error.
0055 
0056 ERRORS
0057 ------
0058 Note that *tpstrerror()* returns generic error message plus custom message 
0059 with debug info from last function call. Error data (tperrno) is valid only 
0060 if return was -1. In case if process was running in *TPNULLCONTEXT*, new 
0061 client context will be made to store the error code.
0062 
0063 *TPENOENT* 'context' is pointing to invalid data.
0064 
0065 *TPESYSTEM* Failed to context data. The state of TLS storage is uncertain.
0066 
0067 EXAMPLE
0068 -------
0069 See *atmitest/test016_contextsw/atmiclt16.c* for sample code.
0070 
0071 BUGS
0072 ----
0073 Report bugs to support@mavimax.com
0074 
0075 SEE ALSO
0076 --------
0077 *tpgetctxt(3)* *tpfreectxt(3)* *tpsrvsetctxdata(3)* *tpsrvgetctxdata(3)*
0078 *tpcontinue(3)* *tpinit(3)*
0079 
0080 COPYING
0081 -------
0082 (C) Mavimax, Ltd
0083