현재 스레드로 그립을 잡으려고 애 쓰고 있습니다. 내 범위와 관련이있을 수 있다는 느낌이 들었습니다. 그러나 나는 이것으로 어디서 잘못 될지 알 수 없다.loops 범위 내의 coldfusion 스레드
내 CFC는 아래의 기능이 포함되어
<cfcomponent output="false" hint="thread stuff.">
<cffunction name="threadTest" access="public" returntype="struct">
<cfscript>
local.lstOne = "1,2,3,4,5,6";
local.a = [];
local.s = {};
local.lst = "";
for(local.x = 1; local.x lte listlen(local.lstOne,','); local.x++){
local.lst &= (len(local.lst) gt 0) ? ',thr#local.x#' : 'thr#local.x#';
thread action="run" name="thr#local.x#" nIndex="#local.x#" aArray="#local.a#"{
thread.y = attributes.nIndex;
thread.aArray = attributes.aArray;
if(thread.y mod 2){
thread.c = 1;
} else {
thread.c = 0;
}
thread.stArgs = {};
thread.stArgs.nMod = thread.c;
arrayAppend(thread.aArray, thread.stArgs);
}
}
threadJoin(local.lst);
local.s.counts = local.a;
return local.s;
</cfscript>
</cffunction>
</cfcomponent>
나는 이런 작은 보이는 CFM 페이지가 있습니다
<cfscript>
theThread = createObject("component", "ThreadStuff").init();
theThread.threadTest();
</cfscript>
내가 이것을 실행, ColdFusion에서 오류 와 함께 다시 온다 요소 X는 LOCAL에서 정의되지 않았습니다..
루프의 첫 번째 반복 후 로컬 x이 손실되는 이유는 해결할 수 없습니다 (루프의 시작 부분과 루프의 끝 부분에서 덤프를 수행하여이를 입증했습니다. local.x = 2)에 도달 할 수 없습니다.
어디서 잘못 될 수 있습니까?
CF 9 (9,0,2,282541)에서 오류없이 실행했습니다. 빈'a' 배열로'counts' 구조체를 반환했습니다. – imthepitts
hmmm 정말 구조체와 함께 구조체를 가진 구조체를 스레드에서 반환해야합니다 ...하지만 그게 아마 내 코드가 틀린 것 같아요, 저의 주요 문제는 local.x가 존재하지 않고 ... 디버깅하는 방법이 확실하지 않습니다. 그 문제. – Jarede
정확한 코드입니까? CFC에'init()'함수가 없기 때문에 처음에는 실패했습니다. 요약 된 버전 인 경우 정확한 코드로 수정하십시오. 오류를 재현 할 수 있기를 바랍니다. – imthepitts