Lee,
We were discussing internally the idea of running multiple
independent makeCalls (in QC Hybrid) in parallel and Josh mentioned
that you had done some work that might be related for Android and
your Node project. I've copied my notes below and would like your
take on this. I'd prefer to use your existing solution or implement
something compatible with it.
Our **** Stack is unnecessarily slow because it runs a number
of independent start up functions in serial. This is because it
needs to run ****() after all of the other functions have
completed AND this is the most obvious way to implement this
functionality.
I am going to address this in one of two ways - whichever is
easier to understand. One is to implement a system of flagging
makeCalls so that they are part of a command set, described in the
attached notes. This seems like it might be a little complicated,
but certainly is possible. However, it involves modifying the
heart of QuickConnect's javascript a bit.
The second idea is to break each piece of parallel
functionality in to its own command stack, which, when otherwise
complete, will call a function that checks to see if it has all of
the necessary information to call ****() and, if so, call it. This
way, when the last required command stack completes,**** () will
be called. I'm going to try this first, since I think it is
simpler.
--- attached text file ---
parallel make calls / make_multiple_calls()
Notes on proposed (Javascript) implementation:
- startMakeCallSet(){
/* - temporarily redefine makeCall to save commands and parameters
into an array? */ // not needed
- temporarily redefines generatePassThroughParameters to return a
unique command set identifier
- creates an array for storing return values for the command set
- changes default behavior of dispatchBCF so it will continue when
undefined is returned and mark that spot in the return value array
as needing a value (use unique command set identifier.)
}
- sendMakeCallSet(){
/* - send array of makeCalls to native */ // also not needed
- return generatePassThroughParams to normal
- return dispatchBCF to normal
}
* need to modify handleRequestCompletionFromNative code to recognize
command set identifiers, fill in the result values where needed, and
determine if all results have been received, and, if so, restart the
command stack.
Need:
Imagine you have a javascript command stack that needs to complete
6 native command stacks that do not rely on each other before
performing another function that relies on all 6. With the current
QuickConnect functionality you are required to perform each of the
calls to native command stacks serially, over a fairly slow
javascript to native interface.
By adding this functionality, we can still write individual
functions focused on triggering the appropriate native command
stack, but they will all be passed to native at (nearly) the same
time, each running in parallel (on its own native thread, where
possible.)
When the native command stack completes, it will still call
handleRequestCompletionFromNative, which will recognize the command
stack identifier as part of a command set and put the returned value
in to the appropriate location in the command set return values
array. When all the command set values have been returned, the
command stack will be resumed as normal with the command set return
values array as the value for the lastBCFIndex of the
previousResults array. The next BCF will be responsible for handling
the results appropriately.
This enables our hypothetical stack to run all its independent
native commands in parallel and then run the mutually dependant
function after all of them have completed.