## Sharing variables between tasks

As well as passing data using the `Signal` method and delta properties, you can also share variables between all the APL tasks you have running (this includes all top-level tasks and all child tasks). You do this using Auxiliary Processor 800, which is built into APLX. All that is required is to share a variable with this processor:

          800 ŒSVO 'TITLE'
    2

This causes the variable TITLE to be held outside the workspace, in a common memory area accessible to any other tasks which use ŒSVO to share the same variable. When you assign to a shared variable of this type, APLX allocates memory for it outside the workspace. If this memory cannot be allocated, an IO ERROR is reported to the APL task. Other than available memory, there are no limits on the size or number of such variables.

The value of the variable will be the last value written to it by any task. This can be any APL array, or an overlay created using ŒOV which contains multiple functions and variables. It persists for as long as any task has the variable shared, and is automatically deleted when it is no longer required (or when APLX exits).

For example:

Share a variable with all other tasks:

          800 ŒSVO 'TITLE'
    2

Assign some data to it:

          TITLE„"Lady Windermere's Fan"

Read it back:

          TITLE
    Lady Windermere's Fan

Read it back again:

          TITLE
    The Importance of Being Earnest

Another task has modified it!

#### Special considerations for Client-Server implementations of APLX

If you are running a Client-Server implementation of APLX, your APL tasks may not all be running on the same machine. In contrast to delta properties, variables shared using Auxiliary Processor 800 are held on the Server machine, so you cannot use this mechanism to share data across the network. In addition, there are separate common data areas for 32-bit and 64-bit tasks.

Topic: APLX Help : Multi-tasking support : Sharing variables between tasks

[ Previous | Contents | Index ]