GlobalResourceEnter Function

Action

Defines a resource that can be occupied by only a limited number of users. The caller has to wait until the number of users who occupy the resource is less than the maximum number of users who are allowed to occupy the resource. To releases a resource, call the GlobalResourceRelease function.

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

Include file

Kernel.bdh

Syntax

GlobalResourceEnter( 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 for the resource occurred. To get more information, call the GetLastError function.
  • GLOBAL_CANCELED if the waiting period was canceled by the controller.
  • GLOBAL_TIMEOUT if the waiting period exceeded the defined timeout and the user continues the simulation.
  • GLOBAL_PASSED if the user has occupied the resource and continues the simulation.
Parameter Description
sName Name to identify a resource.
nCount Number of users who are allowed to enter the resource (optional). If this parameter is omitted, only one user is allowed to enter the resource.
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
    GlobalResourceEnter("Max 5 logins at a time", 5);
    OraLogon(hConnection, "user", "password", "orclnet2");
    GlobalResourceRelease("Max 5 logins at a time");
    GlobalWaitFor("All are logged in");
  end TLogon;