💾 Archived View for blitter.com › apl-books › APLX50 › APLX-manual › www.microapl.com › apl_help › c… captured on 2023-01-29 at 14:38:18.

View Raw

More Information

⬅️ Previous capture (2022-07-17)

-=-=-=-=-=-=-

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Sharing variables between tasks</TITLE>
<META NAME="DESCRIPTION" CONTENT="APL language help page: Sharing variables between tasks">
<META NAME="KEYWORDS" CONTENT="Multi-tasking,Tasks,Shared variables,Common data,apl,aplx,apl help">
<!-- %%COMMON_HEAD%% -->
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="stylesheet" type="text/css" href="http://www.microapl.com/styles_apl_help.css">
<!-- %%END%%-->
</HEAD>
<body>
<table>
<tr>
<td width="800" valign="top" colspan="2">
<center>Topic: <A HREF="ch.htm"><code>APLX Help</code></A> : <A HREF="ch_200.htm"><code>Multi-tasking support</code></A> : <A HREF="ch_200_080.htm"><code>Sharing variables between tasks</code></A> 
</center>
<center>
[ <A HREF="ch_200_070.htm">Previous</A> | <A HREF="ch.htm">Contents</A> | <A HREF="help_index.htm">Index</A>  | <A HREF="http://www.microapl.co.uk/apl/index.html">APL Home</A> ]</center>
<br></td>
</tr>
<tr>
<td width="120">
<a href="http://www.microapl.co.uk/apl/index.html"><img height="68" border="0" width="119" src="MicroAPL_logo.gif" alt="www.microapl.co.uk"></a>
</td>
<td align="left" valign="bottom">
<h1>Sharing variables between tasks</h1>
</td>
</tr>
<tr>
<td width="800" valign="top" colspan="2">
<hr>
<p>As well as passing data using the <tt>Signal</tt> 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:</p>

<pre>      800 &#9109;SVO 'TITLE'
2
</pre>

<p>This causes the variable <code>TITLE</code> to be held outside the workspace, in a
common memory area accessible to any other tasks which use <code>&#9109;SVO</code>
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 <code>IO ERROR</code> is
reported to the APL task.  Other than
available memory, there are no limits on the size or number of such variables.</p>

<p>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 <code>&#9109;OV</code> 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).</p>

<p>For example:</p>

<p><i>Share a variable with all other tasks:</i></p>

<pre>      800 &#9109;SVO 'TITLE'
2
</pre>


<p><i>Assign some data to it:</i></p>

<pre>      TITLE&#8592;&quot;Lady Windermere's Fan&quot;
</pre>

<p><i>Read it back:</i></p>

<pre>      TITLE
Lady Windermere's Fan
</pre>

<p><i>Read it back again:</i></p>


<pre>      TITLE
The Importance of Being Earnest
</pre>

<p><i>Another task has modified it!</i></p>

<H3>Special considerations for Client-Server implementations of APLX</H3>

<p>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.</p> 

<hr>
</td>
</tr>
<tr>
<td width="800" valign="top" colspan="2">
<center>Topic: <A HREF="ch.htm"><code>APLX Help</code></A> : <A HREF="ch_200.htm"><code>Multi-tasking support</code></A> : <A HREF="ch_200_080.htm"><code>Sharing variables between tasks</code></A> 
</center>
<center>
[ <A HREF="ch_200_070.htm">Previous</A> | <A HREF="ch.htm">Contents</A> | <A HREF="help_index.htm">Index</A>  | <A HREF="http://www.microapl.co.uk/apl/index.html">APL Home</A> ]</center>
<br></td>
</tr>
</table>
<!-- %%COMMON_BODY_TAIL%% -->
<p class="copyright">Copyright &copy; 1996-2010 MicroAPL Ltd</p>
<!-- %%END%% -->
</body>
</html>