gtpc2m8z | C/C++ Language Support User's Guide |
This function is a TPF-defined extension to the TX specification published by X/Open Company Limited.
This function resumes a transaction that the entry control block (ECB) of the caller suspended.
Format
#include <tpfapi.h> int tx_resume_tpf();
Normal Return
Table 28. tx_resume_tpf Normal Return
Value Name | Return Code | Description |
---|---|---|
TX_OK | 0 | The function is completed successfully. |
Error Return
Table 29. tx_resume_tpf Error Return
Value Name | Return Code | Description |
---|---|---|
TX_PROTOCOL_ERROR | -5 | The function was called incorrectly. |
TX_FATAL | -7 | The transaction is not suspended. |
Programming Considerations
Examples
The following example shows some of the ways that the tx_suspend_tpf and tx_resume_tpf functions can be used in either root transaction or nested transaction scenarios. The comments to the right of the example code describe which transactions are active and what value is contained in the suspend counter throughout the example.
Transaction 1 is a root transaction that is suspended with the tx_suspend_tpf function before beginning transaction 2 (another root transaction). Transaction 2 is then suspended twice and resumed twice. After the second resume, the suspend counter is zero, so transaction 2 becomes active again. Transaction 2 continues processing and eventually commits. Transaction 1 remains suspended until it is explicitly resumed by the next tx_resume_tpf call.
Next, transaction 3 begins as a nested transaction under transaction 1. The tx_suspend_tpf call then suspends both transaction 3 and transaction 1.
Later, the transactions are both resumed with the tx_resume_tpf function. Eventually the nested transaction commits and the root transaction also commits.
#include <tpfapi.h> tx_begin(); /* begin transaction 1, root */ . tx_suspend_tpf(); /* suspend transaction 1, */ . /* suspend counter = 1. */ . tx_begin(); /* begin transaction 2, root */ . /* not a nested transaction */ . /* transaction 2 is now active */ . tx_suspend_tpf(); /* suspend transaction 2 */ . /* suspend counter = 1. */ . tx_suspend_tpf(); /* suspend transaction 2 again */ . /* suspend counter = 2. */ . tx_resume_tpf(); /* resume transaction 2 */ . /* suspend counter = 1. */ . /* transaction is still suspended*/ . tx_resume_tpf(); /* resume transaction2 */ . /* suspend counter = 0. */ . /* transaction 2 is now active */ . tx_commit(); /* commit transaction 2 */ . . /* transaction 1 is suspended */ . /* suspend counter is 1. */ . tx_resume(); /* transaction 1 is now active */ . /* suspend counter is 0. */ . tx_begin(); /* begin transaction 3, nested */ . . tx_suspend_tpf(); /* suspend transaction 3 and 1 */ . /* suspend counter is 1. */ . tx_resume_tpf(); /* resume transaction 3 and 1 */ . /* suspend counter is 0. */ . /* transaction 3 is now active */ . tx_commit(); /* commit transaction 3 */ . /* transaction 1 is now active */ . tx_commit(); /* commit transaction 1
Related Information