GDSX (Extended General Device Support) Manual

LINE^HANDLER Example, Design
Extended General Device Support (GDSX) Manual529931-001
7-10
Basic Structure of LINE^HANDLER Code
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, LINE^HANDLER
Example, Running and Managing) 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.