Hello,

an alternate solution would be to first stop the loop in thread1 and then to stop the (possibly running) search. (See code below) To avoid a potential race-condition (thread1 at position (2) when StopCalc is called), the stopping is retried until confirmed.
Cells could be used if you want to resume the computation later.

Cheers,

Yves

Harmon Nine wrote:

(...)

Thread 1

Sobj = {New Search.object script(Space CostFunction …)}

LoopStopper = _
HasStopped = _

% loop

proc {GetSolutions}

if {IsFree LoopStopper} then
%(2)

{Sobj next(NextSolution)} % (1)

if NextSolution == stopped then

skip % exit loop

else

Process NextSolution

{GetSolutions} % Next iteration

end

else
HasStopped = unit
end

end

end

Thread 2

proc {StopCalc}

LoopStopper = unit

{Sobj stop}

if {IsFree HasStopped} then {StopCalc} end

end

end

(...)



_________________________________________________________________________________
mozart-hackers mailing list                           
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-hackers

Reply via email to