<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
What is the point of<BR>
<BR>Thread.Wait(Thread.Fork(NEW(ClosureType....));<BR>
<BR>vs. just:<BR>
<BR>NEW(ClosureType....).apply();<BR>
<BR>?<BR>
<BR>The only reason I can think of is to ensure more stack the ClosureType().apply() than might be present on the current thread.<BR>
<BR>OR maybe an assertion on the author's part that the work could/should be performed without waiting, but he hasn't made it so yet?<BR>
<BR>OR maybe so user can interrupt long running operation with control-c? But that works the same on the original thread, right?<BR>
<BR>
OR maybe to stress test the threading library and ensure that thread creation is cheap??<BR>
These do seem like wasted threads.<BR>
<BR>
I have found a few examples. Here is one:<BR>
<BR>
<BR>m3-ui\formsvbt\src\FormsVBT.m3<BR>
<BR>
<BR>PROCEDURE Parse (t: T; description: Sx.T; READONLY state: State): VBT.T<BR> RAISES {Error} =<BR> BEGIN<BR> TYPECASE<BR> Thread.Join (Thread.Fork (NEW (ParseClosure, stackSize := 10000,<BR> description := description, fv := t,<BR> state := state))) OF<BR> | TEXT (msg) => RAISE Error (msg)<BR> | VBT.T (ch) => RETURN ch<BR> ELSE <* ASSERT FALSE *><BR> END<BR> END Parse;<BR>
<BR>
<BR>why not:<BR>
<BR>
<BR>PROCEDURE Parse (t: T; description: Sx.T; READONLY state: State): VBT.T<BR> RAISES {Error} =<BR> BEGIN<BR> TYPECASE<BR> NEW (ParseClosure, stackSize := 10000,<BR> description := description, fv := t,<BR> state := state).apply() OF<BR> | TEXT (msg) => RAISE Error (msg)<BR> | VBT.T (ch) => RETURN ch<BR> ELSE <* ASSERT FALSE *><BR> END<BR> END Parse;<BR>
<BR>
<BR>
If the point is to ensure enough stack, perhaps a mechanism to report how much stack is left would be reasonable??<BR>
<BR>
<BR> - Jay<BR><BR> </body>
</html>