...
In addition to the synchronous proxy method, slice2matlab
generates the following asynchronous proxy method:
Code Block | ||||
---|---|---|---|---|
| ||||
classdef EmployeesPrx < Ice.ObjectPrx methods function result = getName(obj, number, varargin) % Synchronous method ... end function future = getNameAsync(obj, number, varargin) % Asynchronous method ... end end ... end |
...
Here's an example that calls getNameAsync
:
Code Block | ||||
---|---|---|---|---|
| ||||
e = ...; % Get EmployeesPrx proxy future = e.getNameAsync(99); % Continue to do other things here... name = f.fetchOutputs(); |
...
The generated code looks like this:
Code Block | ||||
---|---|---|---|---|
| ||||
classdef ExamplePrx < Ice.ObjectPrx methods function future = opAsync(obj, inp1, inp2, varargin) ... end ... end ... end |
Now let's call fetchOutputs
to demonstrate how to retrieve the results when the invocation completes:
Code Block | ||||
---|---|---|---|---|
| ||||
e = ...; % Get EmployeesPrx proxy future = e.opAsync(5, 'demo'); ... [r, outp1, outp2] = future.fetchOutputs(); |
...
The Future
object that is returned by asynchronous proxy methods has an API that resembles MATLAB's parallel.Future
class:
Code Block | ||||
---|---|---|---|---|
| ||||
classdef Future < ... methods function ok = wait(obj) function varargout = fetchOutputs(obj) function cancel(obj) end properties(SetAccess=private) % Read only properties ID NumOutputArguments Operation Read State end end |
...