Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: servers.getplotter - Function Up: servers - Tool Previous: servers.running - Function


servers.result - Function



Package utility
Module tasking
Tool servers


Get the result(s) from an asynchronous function.


Synopsis
result(jobid, clear)


Description
The results function is used to get the return values after an asynchronous C++ function has finished.

The results for the specified function are obtained using the jobid that is returned when the function is started with the run function. Normally these results are cleared when result is called; however, it is possible to keep them for future access by setting the clear argument to F.

The results are provided in a record format with fields corresponding to each of the input parameters. This is to allow some input parameters to also act as output values. If the C++ function returns a value then the record will also contain a returnval field that contains the value returned by the C++ function.



Arguments

jobid   Which job id we are inquiring about
    Allowed: A positive integer obtained from the run function.
    Default: no default
clear   Delete the results from the internal buffer
    Allowed: T or F
    Default: T


Returns
T, F or a fail


Example
      private.simulateRec := [_method = 'simulate',
    			      _sequence = private.id._sequence];
      public.simulate := function(howmany=1, async=F) {
        wider private;
        private.simulateRec.howmany := howmany;
        retval := defaultservers.run(private.serverid,
                                     private.simulateRec, async);
        if (is_fail(retval)) return retval;
        if (async) {
          t := client("timer", 1.0);
          whenever t->ready do {
    	    if (!defaultservers.running(retval)) {
              t->terminate();
    	      deactivate;
    	      note('Added ', howmany, ' simulated component(s) to the list.',
    	           origin='componentlist.simulate');
    	    }
          }
        } else {
          note('Added ', howmany, ' simulated component(s) to the list.',
    	       origin='componentlist.simulate');
        }
        return T;
      }
This example illustrates how a function can be made to work both synchronously or asynchronously. In either the former case the user waits for the function to complete does not receive a glish prompt until then. In the latter case the functions returns quickly and executation proceeeds in the backgroud. In either case the note is only printed when everything has been done.



next up previous contents index
Next: servers.getplotter - Function Up: servers - Tool Previous: servers.running - Function   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15