aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Germain <b n t DOT g e r m a i n AT g m a i l DOT c o m>2019-04-26 12:20:06 +0200
committerBenoit Germain <b n t DOT g e r m a i n AT g m a i l DOT c o m>2019-04-26 12:20:06 +0200
commit73cb06d3f482d2f9ac7ab7002c1b5f01bfc3add6 (patch)
tree03058a484ad0a57ced10708db4e002b5be4a1294
parent123418beab3404848b27471e2ecfe5d1215c1fcc (diff)
downloadlanes-73cb06d3f482d2f9ac7ab7002c1b5f01bfc3add6.tar.gz
lanes-73cb06d3f482d2f9ac7ab7002c1b5f01bfc3add6.tar.bz2
lanes-73cb06d3f482d2f9ac7ab7002c1b5f01bfc3add6.zip
Lane cancellation rework
opt.cancelstep is gone, hook is installed by lane:cancel() if requested lane:cancel() rework (see doc)
-rw-r--r--index.html47
1 files changed, 22 insertions, 25 deletions
diff --git a/index.html b/index.html
index db8e7a0..0b19223 100644
--- a/index.html
+++ b/index.html
@@ -64,13 +64,13 @@
64 <font size="-1"> 64 <font size="-1">
65 <p> 65 <p>
66 <br/> 66 <br/>
67 <i>Copyright &copy; 2007-18 Asko Kauppi, Benoit Germain. All rights reserved.</i> 67 <i>Copyright &copy; 2007-19 Asko Kauppi, Benoit Germain. All rights reserved.</i>
68 <br/> 68 <br/>
69 Lua Lanes is published under the same <a href="http://en.wikipedia.org/wiki/MIT_License">MIT license</a> as Lua 5.1, 5.2, and 5.3. 69 Lua Lanes is published under the same <a href="http://en.wikipedia.org/wiki/MIT_License">MIT license</a> as Lua 5.1, 5.2, 5.3 and 5.4.
70 </p> 70 </p>
71 71
72 <p> 72 <p>
73 This document was revised on 15-Nov-18, and applies to version <tt>3.13.0</tt>. 73 This document was revised on 26-Apr-19, and applies to version <tt>3.14.0</tt>.
74 </p> 74 </p>
75 </font> 75 </font>
76 </center> 76 </center>
@@ -605,16 +605,6 @@
605 </tr> 605 </tr>
606 <tr valign=top> 606 <tr valign=top>
607 <td> 607 <td>
608 <code>.cancelstep</code>
609 </td>
610 <td>integer >= 1/<tt>true</tt></td>
611 <td>
612 By default, lanes are only cancellable when they <u>enter</u> a pending <tt>:receive()</tt> or <tt>:send()</tt> call. With this option, one can set <a href="#cancelling">cancellation</a> check to occur every <tt>N</tt> Lua statements through the line hook facility. The value <tt>true</tt> uses a default value (100).
613 It is also possible to manually test for cancel requests with <tt>cancel_test()</tt>.
614 </td>
615 </tr>
616 <tr valign=top>
617 <td>
618 <code>.globals</code> 608 <code>.globals</code>
619 </td> 609 </td>
620 <td>table</td> 610 <td>table</td>
@@ -949,32 +939,37 @@
949<h2 id="cancelling">Cancelling</h2> 939<h2 id="cancelling">Cancelling</h2>
950 940
951<table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre> 941<table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre>
952 bool[,reason] = lane_h:cancel( [positive_timeout_secs=0.0] [, force_kill_bool = false] [, forcekill_timeout=0.0]) 942 bool[,reason] = lane_h:cancel( "soft" [, timeout] [, wake_bool])
953 bool[,reason] = lane_h:cancel( negative_timeout_secs [, wake_bool = false]) 943 bool[,reason] = lane_h:cancel( "hard" [, timeout] [, force [, forcekill_timeout]])
944 bool[,reason] = lane_h:cancel( [mode, hookcount] [, timeout] [, force [, forcekill_timeout]])
954</pre></td></tr></table> 945</pre></td></tr></table>
955 946
956<p> 947<p>
957 <tt>cancel()</tt> sends a cancellation request to the lane.<br/> 948 <tt>cancel()</tt> sends a cancellation request to the lane.<br/>
958 First argument is a timeout, that defaults to 0 if not specified. (Starting with version 3.6.3) signification of the following arguments differ depending on whether the timeout is negative or not. 949 First argument is a <tt>mode</tt> can be one of <tt>"hard"</tt>, <tt>"soft"</tt>, <tt>"count"</tt>, <tt>"line"</tt>, <tt>"call"</tt>, <tt>"ret"</tt>.
950 If <tt>mode</tt> is not specified, it defaults to <tt>"hard"</tt>.
959</p> 951</p>
960<p> 952<p>
961 If <tt>timeout_secs</tt> is negative (aka "soft cancel"), cancellation will only cause <tt>cancel_test()</tt> to return <tt>true</tt>, so that the lane can cleanup manually (the actual value is irrelevant). 953 If <tt>mode</tt> is <tt>"soft"</tt>, cancellation will only cause <tt>cancel_test()</tt> to return <tt>true</tt>, so that the lane can cleanup manually.<br/>
962 If <tt>wake_bool</tt> is <tt>true</tt>, the lane is also signalled so that execution returns from any pending linda operation. Linda operations detecting the cancellation request return <tt>lanes.cancel_error</tt>. 954 If <tt>wake_bool</tt> is <tt>true</tt>, the lane is also signalled so that execution returns from any pending linda operation. Linda operations detecting the cancellation request return <tt>lanes.cancel_error</tt>.
963</p> 955</p>
964<p> 956<p>
965 If <tt>timeout_secs</tt> is positive (aka "hard cancel"), waits for the request to be processed, or a timeout to occur. Linda operations detecting the cancellation request will raise a special cancellation error (meaning they won't return in that case). 957 If <tt>mode</tt> is <tt>"hard"</tt>, waits for the request to be processed, or a timeout to occur. Linda operations detecting the cancellation request will raise a special cancellation error (meaning they won't return in that case).<br/>
958 <tt>timeout</tt> defaults to 0 if not specified.
959</p>
960<p>
961 Other values of <tt>mode</tt> will asynchronously install the corresponding hook, then behave as <tt>"hard"</tt>.
962</p>
963<p>
966 If <tt>force_kill_bool</tt> is <tt>true</tt>, <tt>forcekill_timeout</tt> can be set to tell how long lanes will wait for the OS thread to terminate before raising an error. Windows threads always terminate immediately, but it might not always be the case with some pthread implementations. 964 If <tt>force_kill_bool</tt> is <tt>true</tt>, <tt>forcekill_timeout</tt> can be set to tell how long lanes will wait for the OS thread to terminate before raising an error. Windows threads always terminate immediately, but it might not always be the case with some pthread implementations.
967 Returns <tt>true</tt> if soft cancelling, or the lane was already done (in <tt>"done"</tt>, <tt>"error"</tt> or <tt>"cancelled"</tt> status), or the cancellation was fruitful within <tt>timeout_secs</tt> timeout period.
968</p> 965</p>
969
970<p> 966<p>
971 If the lane is still running after the timeout expired and <tt>force_kill</tt> is <tt>true</tt>, the OS thread running the lane is forcefully killed. This means no GC, probable OS resource leaks (thread stack, locks, DLL notifications), and should generally be the last resort. 967 Returns <tt>true, lane_h.status</tt> if lane was already done (in <tt>"done"</tt>, <tt>"error"</tt> or <tt>"cancelled"</tt> status), or the cancellation was fruitful within <tt>timeout_secs</tt> timeout period.<br/>
968 Returns <tt>false, "timeout"</tt> otherwise.
972</p> 969</p>
973
974<p> 970<p>
975 Starting with v3.3.0, if <tt>cancel()</tt> returns false, it also returns either <tt>"timeout"</tt> or <tt>"killed"</tt> as second return value. 971 If the lane is still running after the timeout expired and <tt>force_kill</tt> is <tt>true</tt>, the OS thread running the lane is forcefully killed. This means no GC, probable OS resource leaks (thread stack, locks, DLL notifications), and should generally be the last resort.
976</p> 972</p>
977
978<p> 973<p>
979 Cancellation is tested <u>before</u> going to sleep in <tt>receive()</tt> or <tt>send()</tt> calls and after executing <tt>cancelstep</tt> Lua statements. Starting with version 3.0-beta, a pending <tt>receive()</tt>or <tt>send()</tt> call is awakened. 974 Cancellation is tested <u>before</u> going to sleep in <tt>receive()</tt> or <tt>send()</tt> calls and after executing <tt>cancelstep</tt> Lua statements. Starting with version 3.0-beta, a pending <tt>receive()</tt>or <tt>send()</tt> call is awakened.
980 <br/> 975 <br/>
@@ -1732,7 +1727,9 @@ int luaD_new_clonable( lua_State* L)
1732<h2 id="changes">Change log</h2> 1727<h2 id="changes">Change log</h2>
1733 1728
1734<p> 1729<p>
1735 See CHANGES. 1730 v3.14.0: lane:cancel() rework: opt.cancelstep is gone, hook is installed by lane:cancel() if requested.
1731
1732 For older stuff see CHANGES.
1736</p> 1733</p>
1737 1734
1738<!-- footnotes +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 1735<!-- footnotes +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->