QT Class RadAsynch

 

Overview

The RadAsynch class is the principal tool for creating new AIS asynchronous Lisp workspaces. RadAsynch workspaces can evaluate any Lisp valid expression and return the result to the calling workspace. The RadAsynch is one of the key words accepted by the qt new: function. There can be many RadAsynch objects.

new

Overview

The new function creates a new RadAsynch object and returns a pointer to the newly created object. The RadAsynch is one of the class key words accepted by the qt new: function. There can be many RadAsynch objects.

 

Syntax

(qt new: RadAsynch: heapSize objStack tvalStack cStack)

Arguments

heapSizeThe size of the workspace heap.
objStackThe size of the workspace object stack.
tvalStackThe size of the workspace tval stack.
cStackThe size of the workspace C stack.

 

Example

(setq radAsynchPtr (qt new: RadAsynch: 20000000 1000000 2000000 1000000)) ;; Create a new RadAsynch object
(setq r (qt radAsynchPtr: lisp: "(+ 1 2)")) ;; Runs the expression asynchronously.
(while (= (setq r (qt radAsynchPtr: getResult:)) false) do (sleep 10)) ;; Returns the String "3" when the asynchronous workspace is finished computing.

delete

Overview

The delete function destroys a RadAsynch object and returns a null pointer.

 

Syntax

(qt delete: radAsynchPtr)

Arguments

radAsynchPtrThe pointer to the RadAsynch object to be destroyed.
nullPtrAlways returns a null pointer.

 

Example

(setq radAsynchPtr (qt new: RadAsynch: 5000000 1000000 1000000 1000000)) ;; Create a RadAsynch object.
(setq radAsynchPtr (qt delete: radAsynchPtr)) ;; Destroy the RadAsynch object.

getResult

Overview

The RadAsynch getResult function returns the result of the previous asynchronous Lisp expression evaluation in the workspace. If the workspace has not completed its evaluation, false is returned. The result of the evaluation is always returned as a String object.

 

Syntax

(qt radAsynchPtr getResult:)

Arguments

result Always returns a String result if the expression has been evaluated or false if the workspace is busy.

 

Example

(setq radAsynchPtr (qt new: RadAsynch: 20000000 1000000 2000000 1000000)) ;; Create a new RadAsynch object
(setq r (qt radAsynchPtr: lisp: "(+ 1 2)")) ;; Runs the expression asynchronously.
(while (= (setq r (qt radAsynchPtr: getResult:)) false) do (sleep 10)) ;; Returns the String "3" when the asynchronous workspace is finished computing.

getWriteln

Overview

The RadAsynch getWriteln function returns the String of any previous writelns generated in the asynchronous workspace. If the workspace has not issued any writelns, false is returned. The writelns are always returned as a String object.

 

Syntax

(qt radAsynchPtr getWriteln:)

Arguments

result Always returns the String of any previous writelns generated in the asynchronous workspace. or false if no writelns were generated.

 

Example

(setq radAsynchPtr (qt new: RadAsynch: 20000000 1000000 2000000 1000000)) ;; Create a new RadAsynch object
(setq r (qt radAsynchPtr: lisp: "(loop for n from 0 until 20 do (display n))")) ;; Runs the expression asynchronously.
(while (= (setq r (qt radAsynchPtr: getResult:)) false) do (sleep 10)) ;; Returns the String "20" when the asynchronous workspace is finished computing.
(setq w (qt radAsynchPtr: getWriteln)) ;; Returns the String "012345678910111213141516171819" when the asynchronous workspace is finished computing.

isBusy

Overview

The RadAsynch isBusy function returns true if the asynchronous workspace is busy or false otherwise.

 

Syntax

(qt radAsynchPtr isBusy:)

Arguments

result Always returns true if the asynchronous workspace is busy or false otherwise..

 

Example

(setq radAsynchPtr (qt new: RadAsynch: 20000000 1000000 2000000 1000000)) ;; Create a new RadAsynch object
(setq r (qt radAsynchPtr: lisp: "(loop for n from 0 until 20 do (display n))" ;; Runs the expression asynchronously.
(while (= (setq r (qt radAsynchPtr: isBusy:)) true) do (sleep 10)) ;; Waits until the asynchronous workspace is finished computing.
(setq r (qt radAsynchPtr: getResult:)) ;; Returns the String "20" when the asynchronous workspace is finished computing.
(setq w (qt radAsynchPtr: getWriteln)) ;; Returns the String "012345678910111213141516171819" when the asynchronous workspace is finished computing.

lisp

Overview

The RadAsynch lisp function evaluates the Lisp expression in the new workspace asynchronously.

 

Syntax

(qt radAsynchPtr lisp: expression)

Arguments

expression A Lisp expression to be evaluated
result Always returns true if the expression is being evaluated or false if the workspace was busy.

 

Example

(setq radAsynchPtr (qt new: RadAsynch: 20000000 1000000 2000000 1000000)) ;; Create a new RadAsynch object
(setq r (qt radAsynchPtr: lisp: "(+ 1 2)")) ;; Runs the expression asynchronously.
(while (= (setq r (qt radAsynchPtr: getResult:)) false) do (sleep 10)) ;; Returns the String "3" when the asynchronous workspace is finished computing.

query

Overview

The RadAsynch query function evaluates the Lisp expression in the new workspace asynchronously. The query function is used to evaluate very short expressions when an asynchronous workspace is already busy computing a previous lisp expression. Query expressions should be very short inquiries as to the progress of an asynchronous computation.

 

Syntax

(qt radAsynchPtr query: expression)

Arguments

expression A Lisp query expression to be evaluated
result Always returns true if the query expression is being evaluated or false if the workspace was not busy.

 

Example

(setq radAsynchPtr (qt new: RadAsynch: 20000000 1000000 2000000 1000000)) ;; Create a new RadAsynch object
(setq r (qt radAsynchPtr: lisp: "(loop for n from 0 until N do (display n))")) ;; Runs the expression asynchronously.
;; Runs the query expression asynchronously to find out how far n has incremented.
(while (= (setq r (qt radAsynchPtr: isBusy:)) true) do (setq r (qt radAsynchPtr: query: "n")) (sleep 100) (setq r (qt radAsynchPtr: getQueryResult:)))
(setq r (qt radAsynchPtr: getResult:)) ;; Returns the String "20" when the asynchronous workspace is finished computing.
(setq w (qt radAsynchPtr: getWriteln)) ;; Returns the String "012345678910111213141516171819" when the asynchronous workspace is finished computing.

getQueryResult

Overview

The RadAsynch getQueryResult function returns the result of the previous asynchronous Lisp query expression evaluation in the workspace. If the workspace has completed its evaluation, false is returned. The result of the query evaluation is always returned as a String object.

 

Syntax

(qt radAsynchPtr getQueryResult:)

Arguments

result Always returns a String result if the query expression has not been evaluated or false if the workspace is not busy.

 

Example

(setq radAsynchPtr (qt new: RadAsynch: 20000000 1000000 2000000 1000000)) ;; Create a new RadAsynch object
(setq r (qt radAsynchPtr: lisp: "(loop for n from 0 until N do (display n))")) ;; Runs the expression asynchronously.
;; Runs the query expression asynchronously to find out how far n has incremented.
(while (= (setq r (qt radAsynchPtr: isBusy:)) true) do (setq r (qt radAsynchPtr: query: "n")) (sleep 100) (setq r (qt radAsynchPtr: getQueryResult:)))
(setq r (qt radAsynchPtr: getResult:)) ;; Returns the String "20" when the asynchronous workspace is finished computing.
(setq w (qt radAsynchPtr: getWriteln)) ;; Returns the String "012345678910111213141516171819" when the asynchronous workspace is finished computing.

quit

Overview

The RadAsynch quit function requests that a busy asynchronous workspace quit execution gracefully.

 

Syntax

(qt radAsynchPtr quit:)

Arguments

result Always returns true.

 

Example

(setq radAsynchPtr (qt new: RadAsynch: 20000000 1000000 2000000 1000000)) ;; Create a new RadAsynch object
(setq r (qt radAsynchPtr: lisp: "(loop for n from 0 until N do (display n))")) ;; Runs the expression asynchronously.
(setq r (qt radAsynchPtr: quit:)) ;; Requests that the workspace quit executing gracefully.
(setq w (qt radAsynchPtr: getWriteln)) ;; Returns the String of writelns issued before the workspace quit.