Yves Jaradin wrote:
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.
There is a much clearer solution. Just extend Search.object, redefine
stop(), and provides an explicit reset() method:
local
SearchObject = Search.object
in
class BetterSearchObject from SearchObject
attr stopped: false
meth next($)
if @stopped then stopped else SearchObject,next($) end
end
meth nextS($)
if @stopped then stopped else SearchObject,nextS($) end
end
meth nextP($)
if @stopped then stopped else SearchObject,nextP($) end
end
meth last($)
if @stopped then stopped else SearchObject,last($) end
end
meth lastS($)
if @stopped then stopped else SearchObject,lastS($) end
end
meth lastP($)
if @stopped then stopped else SearchObject,lastP($) end
end
meth stop
stopped := true SearchObject,stop
end
meth reset
stopped := false
end
end
end
Cheers,
raph
_________________________________________________________________________________
mozart-hackers mailing list [email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-hackers