GDSX Manual
LINE^HANDLER Example, Design
Extended General Device Support (GDSX) Manual–134303
7-9
Basic Structure of LINE^HANDLER Code
LINE^HANDLER task calls DEALLOCATEIOCB in order to release the LINE IOCB
that was allocated by TSCODE.
The DEVICE^HANDLER task receives the reply that its ^WRITE has completed, and
passes the error code on to the requester. The transaction is then complete.
Basic Structure of LINE^HANDLER Code
A LINE^HANDLER task starts when TSCODE calls the LINE^HANDLER procedure.
After any necessary initialization processing, the task runs in a continuous loop, reading
from its $RECEIVE-like queue, never doing a RETURN to TSCODE, as shown in
Figure 7-4. TSCODE uses a nonpreemptive type of task scheduling so USCODE must
voluntarily give up control before TSCODE switches to the next ready task.
At different points you may give up control to TSCODE; for example, when you do a
WAIT^EVENT, your task is suspended, but you never actually exit from the
LINE^HANDLER procedure. A LINE^HANDLER task is stopped by TSCODE when
the GDSX process is stopped (see the last commands in Section 6) or when TSCODE
receives a message from SCF to stop a LINE object or stop a LINE task with no
openers.
This simple LINE^HANDLER is multithreaded. In the loop, the first thing done is a
^READUPDATE (not a Guardian READUPDATE) on the $RECEIVE-like queue with a
file number in the variable in^queue^file^num, which is passed when this task is created.
This queue receives all messages sent from the DEVICE^HANDLER tasks. Unlike a
^READUPDATE in a DEVICE^HANDLER task, a ^READUPDATE in a
LINE^HANDLER task does not cause TSCODE to put data into a buffer specified in the
call. Data must be accessed by way of the IOCB provided through a call to ^LISTEN.