gtpa2m1l | Application Programming |
You need to explicitly define the start and end of a commit scope in the
application program; this is commonly referred to as a begin
transaction.
The TPF system provides a subset of TX functions (defined by the X/Open TX
interface) to the application to begin and end (that is, commit or roll back)
a transaction:
Table 10. TPF Transaction Services Begin and End Transactions
C Function | Assembler Macro |
---|---|
tx_begin | TXBGC |
tx_commit | TXCMC |
tx_rollback | TXRBC |
|
Additionally, the TPF system provides the following extension (to
X/Open) functions to the application to suspend or resume a
transaction:
Table 11. TPF Transaction Services Suspend and Resume Transactions
C Function | Assembler Macro |
---|---|
tx_suspend_tpf | TXSPC |
tx_resume_tpf | TXRSC |
|
Commit scope nesting provides a powerful mechanism for fine-tuning the scope of a rollback transaction (that is, the tx_rollback C function or the TXRBC assembler macro) in applications with a complex structure. The term nesting is used whenever a begin transaction is requested and a commit scope is already active. An application may consist of multiple processes where each process is responsible for its own commit scope. This environment can be represented by root and nested commit scopes.
The root commit scope is the first commit scope that is activated by the application. Figure 12 shows a begin and a commit transaction in a simple commit scope. The begin transaction could be either the TXBGC macro or the tx_begin C function. The commit transaction could be either the TXCMC macro or the tx_commit C function.
A nested commit scope is a commit scope that is activated after the root scope has been activated. A root commit scope may have many nested scopes. A nested scope may, in turn, have its own nested scopes. Figure 13 shows a root scope, which is started with the first begin transaction followed by three nested scopes. The first begin transaction is the highest-level scope. The fourth begin transaction is the lowest-level scope; this is the last commit scope to open before the root scope is either committed or rolled back.