IFSTHRD (HLI function)

From m204wiki
Revision as of 21:23, 8 July 2016 by ELowell (talk | contribs) (Created page with " ==Summary== <dl> <dt>Description</dt> <dd>The IFSTHRD call (SWITCH THREAD) deactivates the current thread and activates the specified thread.</dd> <dt>Thread type</dt> <dd>mu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Summary

Description
The IFSTHRD call (SWITCH THREAD) deactivates the current thread and activates the specified thread.
Thread type
multiple cursor IFSTRT, single cursor IFSTRT
IFCALL function number
2

Syntax

IFSTHRD|IFSTRD(RETCODE,NEW_ID,OLD_ID)

Compile-only form
Not available
Execute-only form
Not available

Specify the parameters in the syntax order shown above.

Parameter Description
RETCODE [O,i,r] The Model 204 return code is a required output parameter. The code is a binary integer value.
NEW_ID [I,i,r] The new thread identifier is a required input parameter that identifies the thread to be made current. This is the thread identifier previously assigned by the IFSTRT or IFSTRTN call that started the thread. Specify an integer value.
OLD_ID [O,i,r] The old thread identifier is a required output parameter that identifies the thread that is being deactivated. Model 204 returns the integer value that identifies the current thread.

Usage notes

Use the IFSTHRD call to switch from the current thread to another, while holding the connection with the old thread. IFSTHRD involves low overhead. Note that you cannot use IFSTHRD to deactivate the current thread without specifying a new thread.

You can use the IFSTHRD call on any type of IFSTRT thread except for IFAM1. IFSTHRD is not valid for use with an IFAM1 thread.

The IFSTHRD call is useful for switching threads in a multithreaded IFAM2 or IFAM4 application using single cursor IFSTRT threads, for parallel processing of several sets of records, or for cross-referencing between records in different files.

See HLI: IFAM2/IFAM4 job program examples for an example of a multithreaded application. See HLI: Threads for information about multithreaded IFSTRT transactions.

Completion return code (RETCODE)

If the IFSTHRD call is unsuccessful, Model 204 returns an error code of 95 if a nonexistent new thread is specified and ignores the call.

Coding example (COBOL)

WORKING-STORAGE SECTION. 01 START-ARGS. 05 COBOL-IND PIC 9(8) VALUE 2. 05 LOGIN-INFO PIC X(12) VALUE 'USERX;PASSW;'. 05 ACCESS-MODE PIC 9(8) VALUE 0. 01 THREAD-NBR. 05 FILEA-THREAD-NBR PIC 9(8). 05 FILEB-THREAD-NBR PIC 9(8). 05 THREAD-NBR PIC 9(8). 01 WORK-ARGS. 05 RETCODE PIC 9(5) COMP SYNC. 05 FILE-NAME PIC X(6). . . . PROCEDURE DIVISION. BEGIN-RTN. MOVE "APPLES" TO FILE-NAME. PERFORM START-THREAD. IF (RETCODE = ZERO) OR (RETCODE =16) THEN MOVE THREAD-NBR TO FILEA-THREAD-NBR. MOVE "BANANA" TO FILE-NAME PERFORM START-THREAD. IF (RETCODE = ZERO) OR (RETCODE =16) THEN MOVE THREAD-NBR TO FILEB-THREAD-NBR. START-THREAD. CALL "IFSTRT" USING RETCODE, COBOL-IND, LOGIN-INFO, ACCESS-MODE, THREAD-NBR. . . . GET-FILEA-REC. CALL "IFSTHRD" USING RETCODE, FILEA-THREAD-NBR, THREAD-NBR. . . . GET-FILEB-REC. CALL "IFSTHRD" USING RETCODE, FILEB-THREAD-NBR, THREAD-NBR. . . .