use of org.ballerinalang.bre.bvm.WorkerData in project ballerina by ballerina-lang.
the class BLangFunctions method invokeNonNativeCallableAsync.
public static void invokeNonNativeCallableAsync(CallableUnitInfo callableUnitInfo, WorkerExecutionContext parentCtx, int[] argRegs, int[] retRegs) {
WorkerSet workerSet = callableUnitInfo.getWorkerSet();
int generalWorkersCount = workerSet.generalWorkers.length;
AsyncInvocableWorkerResponseContext respCtx = new AsyncInvocableWorkerResponseContext(callableUnitInfo, generalWorkersCount);
WorkerDataIndex wdi = callableUnitInfo.retWorkerIndex;
/* execute the init worker and extract the local variables created by it */
WorkerData initWorkerLocalData = null;
CodeAttributeInfo initWorkerCAI = null;
if (workerSet.initWorker != null) {
initWorkerLocalData = executeInitWorker(parentCtx, argRegs, callableUnitInfo, workerSet.initWorker, wdi);
if (initWorkerLocalData == null) {
handleError(parentCtx);
return;
}
initWorkerCAI = workerSet.initWorker.getCodeAttributeInfo();
}
List<WorkerExecutionContext> workerExecutionContexts = new ArrayList<>();
/* execute all the workers in their own threads */
for (int i = 0; i < generalWorkersCount; i++) {
workerExecutionContexts.add(executeWorker(respCtx, parentCtx, argRegs, callableUnitInfo, workerSet.generalWorkers[i], wdi, initWorkerLocalData, initWorkerCAI, false));
}
/* set the worker execution contexts in the response context, so it can use them to do later
* operations such as cancel */
respCtx.setWorkerExecutionContexts(workerExecutionContexts);
/* create the future encapsulating the worker response context, and set it as the return value
* to the parent */
BLangVMUtils.populateWorkerDataWithValues(parentCtx.workerLocal, retRegs, new BValue[] { new BCallableFuture(callableUnitInfo.getName(), respCtx) }, new BType[] { BTypes.typeFuture });
return;
}
use of org.ballerinalang.bre.bvm.WorkerData in project ballerina by ballerina-lang.
the class BLangVMUtils method createWorkerDataForLocal.
public static WorkerData createWorkerDataForLocal(WorkerInfo workerInfo, WorkerExecutionContext parentCtx, int[] argRegs, BType[] paramTypes) {
WorkerData wd = createWorkerData(workerInfo);
BLangVMUtils.copyArgValues(parentCtx.workerLocal, wd, argRegs, paramTypes);
return wd;
}
Aggregations