beginTransientTransaction Instruction

The beginTransientTransaction instruction indicates the start of a transaction that updates shared transient objects; that is, transient objects that are to be shared by two or more processes on the same node.

Syntax

The syntax of the beginTransientTransaction instruction is:

beginTransientTransaction;

Description

Transient transactions allow the updating of shared transient objects only. (Use the beginTransaction instruction to update persistent objects.)

For details about creating shared transient objects, see "create Instruction", later in this chapter. See also "Object Class", in Chapter 1 of the Encyclopaedia of Classes.

The beginTransientTransaction instruction causes the Jade Object Manager to place the process in transient transaction state. For more details, see "Locking Objects", in Chapter 6.

A transient transaction has two effects, as follows.

Use the sharedTransient modifier of the create instruction to create transient objects, which can be shared across threads; for example:

create obj sharedTransient;

Shared transient objects can be updated only within transient transaction state. All locks (both manual and automatic) of shared transient objects are released at the end of the transient transaction. The transient transaction state is specified by the beginTransientTransaction and commitTransientTransaction instructions.

You should explicitly create transient objects that need to be shared across processes in a node as shared transient objects, which are updated only within transient transactions.

Updates to shared transient objects are applied when the commitTransientTransaction instruction is executed. As shared transient objects are exclusively locked while being updated, other processes cannot lock these objects until the commitTransientTransaction instruction is executed. Other processes attempting to access these objects without locking will not see the uncommitted updates but instead will view the most‑recently committed editions.

No transaction is necessary when creating, deleting, or updating ordinary non-shared transient objects. These objects can be updated at any time.

All lock operations are enforced for shared transient objects. These actions guarantee an access protocol for shared transient objects similar to that of persistent objects, which is essential for the execution of synchronized multithreaded update operations. For more details about transient objects, see:

Example

The following example shows the use of the beginTransientTransaction instruction.

createArray(anObj: Object) updating;
vars
    array : ObjectArray;
begin
    beginTransientTransaction;
    create arr sharedTransient;
    array.add(anObj);
    commitTransientTransaction;
end;