GlobalWaitFor Function

Action

Defines a checkpoint (rendezvous point) and blocks the calling user. The caller waits until a specified number of users (himself inclusive) have reached or passed the checkpoint, or until the specified timeout occurs. The checkpoint is identified by name and is visible for all users, including those running on various remote agents.

A waiting user continues when the specified timeout is reached or the given number of users have called the function for a checkpoint. A user who was timed out has passed the checkpoint and is also regarded as a user who has passed this checkpoint.

Note: The time that a virtual user spends in this synchronization function does not influence the transaction busy time.

Include file

Kernel.bdh

Syntax

GlobalWaitFor( in sName    : string,
               in nCount   : number optional,
               in nTimeout : number optional ): number;

Return value

  • GLOBAL_ERROR if an error like an invalid number of users at the checkpoint occurred. To get more information, call the GetLastError function.
  • GLOBAL_CANCELED if the waiting period was canceled by the controller computer.
  • GLOBAL_TIMEOUT if the waiting period exceeded the defined timeout and the user continues the simulation.
  • GLOBAL_PASSED if all users have reached the checkpoint the user was waiting for and the user continues the simulation.
  • GLOBAL_SYNCHRONIZED if all users have reached the checkpoint the user was waiting for. The user was the last one to enter the checkpoint and continues the simulation.
Parameter Description
sName Name to identify the checkpoint
nCount Number of users who must reach or pass the checkpoint (optional). To specify to wait for all users, omit this parameter or specify ALL_USERS.
nTimeout Maximum waiting time in seconds before a timeout occurs (optional). If this parameter is omitted, the timeout is set to INFINITE.

Example

var
  hConnection: number;
dcltrans
  transaction TLogon
  var
    nRet: number;
begin
  OraLogon(hConnection, "user", "password", "orclnet2");
  nRet := GlobalWaitFor("All are logged in", ALL_USERS, 300);
  if nRet = GLOBAL_SYNCHRONIZED then
    Print("I am the last user at the checkpoint");
  end;
end TLogon;