use of org.ballerinalang.bre.bvm.WorkerExecutionContext in project ballerina by ballerina-lang.
the class BLangFunctions method invokeNativeCallableAsync.
private static void invokeNativeCallableAsync(CallableUnitInfo callableUnitInfo, WorkerExecutionContext parentCtx, int[] argRegs, int[] retRegs) {
WorkerData caleeSF = BLangVMUtils.createWorkerDataForLocal(callableUnitInfo.getDefaultWorkerInfo(), parentCtx, argRegs, callableUnitInfo.getParamTypes());
Context nativeCtx = new NativeCallContext(parentCtx, callableUnitInfo, caleeSF);
NativeCallableUnit nativeCallable = callableUnitInfo.getNativeCallableUnit();
if (nativeCallable == null) {
return;
}
AsyncInvocableWorkerResponseContext respCtx;
if (nativeCallable.isBlocking()) {
respCtx = BLangScheduler.executeBlockingNativeAsync(nativeCallable, nativeCtx);
} else {
respCtx = BLangScheduler.executeNonBlockingNativeAsync(nativeCallable, nativeCtx);
}
BLangVMUtils.populateWorkerDataWithValues(parentCtx.workerLocal, retRegs, new BValue[] { new BCallableFuture(callableUnitInfo.getName(), respCtx) }, new BType[] { BTypes.typeFuture });
}
use of org.ballerinalang.bre.bvm.WorkerExecutionContext in project ballerina by ballerina-lang.
the class BLangFunctions method executeWorker.
private static WorkerExecutionContext executeWorker(WorkerResponseContext respCtx, WorkerExecutionContext parentCtx, int[] argRegs, CallableUnitInfo callableUnitInfo, WorkerInfo workerInfo, WorkerDataIndex wdi, WorkerData initWorkerLocalData, CodeAttributeInfo initWorkerCAI, boolean runInCaller) {
WorkerData workerLocal = BLangVMUtils.createWorkerDataForLocal(workerInfo, parentCtx, argRegs, callableUnitInfo.getParamTypes());
if (initWorkerLocalData != null) {
BLangVMUtils.mergeInitWorkertData(initWorkerLocalData, workerLocal, initWorkerCAI);
}
WorkerData workerResult = BLangVMUtils.createWorkerData(wdi);
WorkerExecutionContext ctx = new WorkerExecutionContext(parentCtx, respCtx, callableUnitInfo, workerInfo, workerLocal, workerResult, wdi.retRegs, runInCaller);
BLangScheduler.schedule(ctx);
return ctx;
}
use of org.ballerinalang.bre.bvm.WorkerExecutionContext in project ballerina by ballerina-lang.
the class BLangFunctions method invokePackageInitFunction.
public static void invokePackageInitFunction(FunctionInfo initFuncInfo) {
WorkerExecutionContext context = new WorkerExecutionContext(initFuncInfo.getPackageInfo().getProgramFile());
invokePackageInitFunction(initFuncInfo, context);
}
use of org.ballerinalang.bre.bvm.WorkerExecutionContext in project ballerina by ballerina-lang.
the class BLangFunctions method invokeCallable.
public static WorkerExecutionContext invokeCallable(CallableUnitInfo callableUnitInfo, WorkerExecutionContext parentCtx, int[] argRegs, int[] retRegs, boolean waitForResponse, int flags) {
if (FunctionFlags.isObserved(flags)) {
BLangVMUtils.initClientConnectorTrace(parentCtx, callableUnitInfo.attachedToType.toString(), callableUnitInfo.getName());
}
BLangScheduler.workerWaitForResponse(parentCtx);
WorkerExecutionContext resultCtx;
if (callableUnitInfo.isNative()) {
if (FunctionFlags.isAsync(flags)) {
invokeNativeCallableAsync(callableUnitInfo, parentCtx, argRegs, retRegs);
resultCtx = parentCtx;
} else {
resultCtx = invokeNativeCallable(callableUnitInfo, parentCtx, argRegs, retRegs, flags);
}
} else {
if (FunctionFlags.isAsync(flags)) {
invokeNonNativeCallableAsync(callableUnitInfo, parentCtx, argRegs, retRegs);
resultCtx = parentCtx;
} else {
resultCtx = invokeNonNativeCallable(callableUnitInfo, parentCtx, argRegs, retRegs, waitForResponse, flags);
}
}
resultCtx = BLangScheduler.resume(resultCtx, true);
return resultCtx;
}
use of org.ballerinalang.bre.bvm.WorkerExecutionContext in project ballerina by ballerina-lang.
the class BLangFunctions method executeWorker.
private static WorkerExecutionContext executeWorker(WorkerResponseContext respCtx, WorkerExecutionContext parentCtx, int[] argRegs, WorkerInfo workerInfo, Map<String, Object> globalProps, boolean runInCaller) {
WorkerData workerLocal = BLangVMUtils.createWorkerDataForLocal(workerInfo, parentCtx, argRegs);
WorkerExecutionContext ctx = new WorkerExecutionContext(parentCtx, respCtx, parentCtx.callableUnitInfo, workerInfo, workerLocal, runInCaller);
return BLangScheduler.schedule(ctx);
}
Aggregations