RPI Number: 1109756
Product: ACUCOBOL-GT
Module: runtime
Machines Affected: All
Known Versions Affected: All
In a multi-threaded environment, previous behavior was such that the Return-Code or Return-Unsigned special registers could be updated by any subprogram, from any thread in the run unit. This behavior could make it difficult when debugging multithreaded programs.
As of this version, the Return-Code and Return-Unsigned values are stored locally to each COBOL thread. Within COBOL, these 'local' special registers behave exactly the same as they did previously; and for non-COBOL programs, you can still reference the external return_code as defined in sub.h, and it will be echoed by the thread-local value in a thread-safe fashion. (For COBOL threads, if you create operating threads outside of COBOL, you are still responsible for your own thread safety.)
Although this change should not affect the large majority of programs, there is one (uncommon) scenario that may need to be worked around; consider:
CALL THREAD "SUB1" ... IF RETURN-CODE ...
With the new behavior, RETURN-CODE will not contain the return value for SUB1 (that will be contained within the SUB1 thread), and so you may experience unpredictable behavior with this type of construction. A work-around is to re-code as follows:
77 RCODE SIGNED-LONG. CALL THREAD "SUB1" GIVING RCODE IF RCODE …
This type of construction provides the same behavior as before, and is thread-safe. The local Return-Code for the SUB1 program is copied to RCODE, and can then be safely used in the calling program. The same principle also applies to the use of Return-Unsigned.