Skip to content
Permalink
Browse files

fix(job): fix worker->add custom job->"if action is BEFORE, the custo…

…m job is executed after the source job(in pipeline)" bug

(refactor(worker): rename DetectEnvironmentWorkerJob to DetectEnvironmentMainWorkerJob)
  • Loading branch information...
yyc-git committed May 17, 2019
1 parent ae357a3 commit 4db344d1b6f69d8357ce652615059b12789f5a70
@@ -1,7 +1,7 @@
open StateDataMainType;

let _getMainInitJobHandles = () => [
("detect_environment", DetectEnvironmentWorkerJob.execJob),
("detect_environment", DetectEnvironmentMainWorkerJob.execJob),
("init_imgui", InitIMGUIMainWorkerJob.execJob),
("init_event", InitEventMainWorkerJob.execJob),
("init_script", InitScriptMainWorkerJob.execJob),
@@ -60,7 +60,7 @@ let detectMobileNotSupportWorker = state =>
isMobile(state) ?
WonderLog.Log.fatal(
WonderLog.Log.buildFatalMessage(
~title="DetectEnvironmentWorkerJob->execJob",
~title="DetectEnvironmentMainWorkerJob->execJob",
~description={j|mobile not support worker|j},
~reason="",
~solution={j||j},
@@ -11,58 +11,57 @@ let _buildStreamArr =
pipelineJobs: array(mainInitPipelineJob),
pipelineSubJobs: array(mainInitPipelineSubJob),
stateData,
jobs
jobs,
),
findFunc,
getJobHandleFunc,
state
state,
) =>
pipelineSubJobs
|> Js.Array.filter(
({name}: mainInitPipelineSubJob) =>
! (
state.jobRecord.workerCustomMainInitRemovedDefaultJobMap
|> WonderCommonlib.MutableHashMapService.has(name)
)
|> Js.Array.filter(({name}: mainInitPipelineSubJob) =>
!(
state.jobRecord.workerCustomMainInitRemovedDefaultJobMap
|> WonderCommonlib.MutableHashMapService.has(name)
)
)
|> WonderCommonlib.ArrayService.reduceOneParam(
[@bs]
(
(streamArr, {name: subJobName}: mainInitPipelineSubJob) =>
switch (
JobConfigService.findFirst(
pipelineJobs,
(. streamArr, {name: subJobName}: mainInitPipelineSubJob) =>
switch (
JobConfigService.findFirst(pipelineJobs, subJobName, ({name}) =>
JobConfigService.filterTargetName(name, subJobName)
)
) {
| None =>
let {flags} =
OperateMainWorkerJobMainService.getExecutableJob(
jobs,
subJobName,
({name}) => JobConfigService.filterTargetName(name, subJobName)
)
) {
| None =>
let {flags} = OperateMainWorkerJobMainService.getExecutableJob(jobs, subJobName);
let handleFunc = getJobHandleFunc(subJobName, jobHandleMap);
streamArr
|> ArrayService.push(handleFunc(flags, stateData))
|> OperateMainWorkerJobMainService.addCustomJobHandleToStreamArr(
subJobName,
state.jobRecord.workerCustomMainInitTargetJobMap,
stateData
)
| Some(jobRecord) =>
streamArr
|> ArrayService.push(
findFunc(
(jobRecord, pipelineJobs, jobHandleMap, jobs, stateData),
getJobHandleFunc,
state
)
)
|> OperateMainWorkerJobMainService.addCustomJobHandleToStreamArr(
subJobName,
state.jobRecord.workerCustomMainInitTargetJobMap,
stateData
)
}
),
[||]
);
let handleFunc = getJobHandleFunc(subJobName, jobHandleMap);
streamArr
|> OperateMainWorkerJobMainService.addCustomJobHandleToStreamArr(
subJobName,
[|handleFunc(flags, stateData)|],
state.jobRecord.workerCustomMainInitTargetJobMap,
stateData,
);
| Some(jobRecord) =>
streamArr
|> ArrayService.push(
findFunc(
(jobRecord, pipelineJobs, jobHandleMap, jobs, stateData),
getJobHandleFunc,
state,
),
)
|> OperateMainWorkerJobMainService.addCustomJobHandleToStreamArr(
subJobName,
[||],
state.jobRecord.workerCustomMainInitTargetJobMap,
stateData,
)
},
[||],
);

let rec _find =
@@ -72,26 +71,26 @@ let rec _find =
pipelineJobs,
jobHandleMap,
mainInitJobs,
stateData
stateData,
),
getJobHandleFunc,
state
state,
) =>
switch link {
switch (link) {
| "merge" =>
_buildStreamArr(
(jobHandleMap, pipelineJobs, pipelineSubJobs, stateData, mainInitJobs),
_find,
getJobHandleFunc,
state
state,
)
|> WonderBsMost.Most.mergeArray
| "concat" =>
_buildStreamArr(
(jobHandleMap, pipelineJobs, pipelineSubJobs, stateData, mainInitJobs),
_find,
getJobHandleFunc,
state
state,
)
|> MostUtils.concatArray
| _ =>
@@ -101,53 +100,55 @@ let rec _find =
~description={j|invalid link: $link|j},
~reason="",
~solution={j||j},
~params={j||j}
)
~params={j||j},
),
)
};

let _getFrameJobName = () => "frame";

let _findFrameJob = (jobs) => {
let _findFrameJob = jobs => {
WonderLog.Contract.requireCheck(
() =>
WonderLog.(
Contract.(
Operators.(
test(
Log.buildAssertMessage(~expect={j|frame job only has one|j}, ~actual={j|not|j}),
Log.buildAssertMessage(
~expect={j|frame job only has one|j},
~actual={j|not|j},
),
() =>
jobs
|> Js.Array.filter(
({name}: mainInitPipelineJob) =>
JobConfigService.filterTargetName(name, _getFrameJobName())
)
|> Js.Array.length == 1
jobs
|> Js.Array.filter(({name}: mainInitPipelineJob) =>
JobConfigService.filterTargetName(name, _getFrameJobName())
)
|> Js.Array.length == 1
)
)
)
),
IsDebugMainService.getIsDebug(StateDataMain.stateData)
IsDebugMainService.getIsDebug(StateDataMain.stateData),
);
let jobName = _getFrameJobName();
JobConfigService.unsafeFindFirst(
jobs,
jobName,
({name}: mainInitPipelineJob) => JobConfigService.filterTargetName(name, jobName)
)
jobs, jobName, ({name}: mainInitPipelineJob) =>
JobConfigService.filterTargetName(name, jobName)
);
};

let getMainInitJobStream = (jobHandleMap, stateData, getJobHandleFunc, {workerJobRecord} as state) => {
let {setting, mainInitPipelines, mainInitJobs} = workerJobRecord |> OptionService.unsafeGet;
let getMainInitJobStream =
(jobHandleMap, stateData, getJobHandleFunc, {workerJobRecord} as state) => {
let {setting, mainInitPipelines, mainInitJobs} =
workerJobRecord |> OptionService.unsafeGet;
let {jobs}: mainInitPipeline =
JobConfigService.unsafeFindFirst(
mainInitPipelines,
setting.mainInitPipeline,
({name}) => JobConfigService.filterTargetName(name, setting.mainInitPipeline)
mainInitPipelines, setting.mainInitPipeline, ({name}) =>
JobConfigService.filterTargetName(name, setting.mainInitPipeline)
);
_find(
(_findFrameJob(jobs), jobs, jobHandleMap, mainInitJobs, stateData),
getJobHandleFunc,
state
)
state,
);
};

0 comments on commit 4db344d

Please sign in to comment.
You can’t perform that action at this time.