Skip to content

Commit

Permalink
fix(job): fix worker->add custom job->"if action is BEFORE, the custo…
Browse files Browse the repository at this point in the history
…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 4db344d
Show file tree
Hide file tree
Showing 10 changed files with 636 additions and 540 deletions.
2 changes: 1 addition & 1 deletion src/job/worker/WorkerJobHandleSystem.re
@@ -1,7 +1,7 @@
open StateDataMainType; open StateDataMainType;


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


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


let _getFrameJobName = () => "frame"; let _getFrameJobName = () => "frame";


let _findFrameJob = (jobs) => { let _findFrameJob = jobs => {
WonderLog.Contract.requireCheck( WonderLog.Contract.requireCheck(
() => () =>
WonderLog.( WonderLog.(
Contract.( Contract.(
Operators.( Operators.(
test( 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 jobs
|> Js.Array.filter( |> Js.Array.filter(({name}: mainInitPipelineJob) =>
({name}: mainInitPipelineJob) => JobConfigService.filterTargetName(name, _getFrameJobName())
JobConfigService.filterTargetName(name, _getFrameJobName()) )
) |> Js.Array.length == 1
|> Js.Array.length == 1
) )
) )
) )
), ),
IsDebugMainService.getIsDebug(StateDataMain.stateData) IsDebugMainService.getIsDebug(StateDataMain.stateData),
); );
let jobName = _getFrameJobName(); let jobName = _getFrameJobName();
JobConfigService.unsafeFindFirst( JobConfigService.unsafeFindFirst(
jobs, jobs, jobName, ({name}: mainInitPipelineJob) =>
jobName, JobConfigService.filterTargetName(name, jobName)
({name}: mainInitPipelineJob) => JobConfigService.filterTargetName(name, jobName) );
)
}; };


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

0 comments on commit 4db344d

Please sign in to comment.