In some scenarios, Pegasus may send an intermediate response to the application before the requested operation is completed and the final response (RES_DONE or RES_ERROR) is sent.
The application can choose between two different modes of receiving and handling these intermediate responses from Pegasus:
Callback Function (DeferFn) Mode
- Application provides a response-handling (call back) function pointer in the PIC_PARM data. The function is called by Pegasus to send an intermediate response back to the application.
- The application logic to process the intermediate response is coded in the call back function. A nonzero return value from the call back function to Pegasus is a signal to Pegasus to abort processing. A zero return value indicates that Pegasus should continue processing
- This mode is available in all platforms and CPU architectures.
- This mode is selected by setting the F_UseDeferFn flag in PIC_PARM.Flags and assigning a value to PIC_PARM.DeferFn.
Coroutine Mode
- In this mode, the application’s call to Pegasus returns whenever an intermediate response is to be sent back to the application. If the return code is different from RES_DONE or RES_ERROR, then it is an intermediate response.
- The application performs any required action, if needed, and continues processing by calling Pegasus again using a REQ_CONT request parameter or aborts processing by calling Pegasus again using a REQ_TERM request parameter.
- This is the mode whenever the F_UseDeferFn flag is not set in PIC_PARM.Flags. On iOS and Android this mode is based on a stack switching scheme where the opcode uses an internally-allocated stack that is distinct from the application stack. This is known as Stack Based Coroutine Mode.