{"id":357,"date":"2015-02-24T07:42:22","date_gmt":"2015-02-24T07:42:22","guid":{"rendered":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/?page_id=357"},"modified":"2017-12-05T19:43:07","modified_gmt":"2017-12-05T19:43:07","slug":"the-timeout-module","status":"publish","type":"page","link":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/?page_id=357","title":{"rendered":"The timeout module"},"content":{"rendered":"<p>The <code>timeout<\/code> module is an <a href=\"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/?page_id=656\">extension module<\/a>. \u00a0Its purpose is to add new primitives to the <a href=\"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/?page_id=279\">Orchids language<\/a>.<\/p>\n<p>As a preliminary warning, using the <code>timeout<\/code> module to kill useless Orchids threads is in general a bad idea, because Orchids is clever enough to kill them by itself.<\/p>\n<p>One may also think of using the <code>timeout<\/code> module to wait for an event for some amount of time, and stop waiting once that has elapsed, but that is also a wrong idea. \u00a0Usually, the events we monitor have some form of time field, and the correct way to do this is something like:<br \/>\n<code>expect (<\/code>\u27e8what I am waiting for\u27e9<code> &amp;&amp;\u00a0<\/code>\u27e8my time field\u27e9<code>&lt;$timeout) goto<\/code>\u27e8wherever\u27e9<code>;<\/code><br \/>\nwhere <code>$timeout<\/code> holds the final time after which we will no longer care whether\u00a0\u27e8what I am waiting for\u27e9 happened or not. \u00a0Orchids is clever enough to stop waiting after receiving the first event whose\u00a0\u27e8my time field\u27e9 field is larger than or equal to <code>$timeout<\/code>, provided that\u00a0\u27e8my time field\u27e9 is flagged as monotonic, which is usually the case for time fields and sequence numbers.<\/p>\n<p>The <code>timeout<\/code> module has a different purpose, and is meant to schedule so-called\u00a0<code>.timeout<\/code> events to happen after some delay. \u00a0By <em>delay<\/em>, we mean actual time, not any time field recorded in events. \u00a0The difference is best explained by a thought experiment. \u00a0Imagine you run Orchids on a file, holding events over a span of two hours. \u00a0Orchids will probably read all those events in a fraction of a second, but calling <code>timeout(\"blah\", 60)<\/code> will only send a <code>.timeout<\/code> event 60 seconds later, way after the whole file has been read.<\/p>\n<h3>Configuration options<\/h3>\n<p>None.<\/p>\n<h3>Primitives<\/h3>\n<ul>\n<li><strong><code>timeout<\/code><\/strong> : <code>str<\/code>, <code>int<\/code> \u2192 <code>int<\/code><br \/>\nset a real-time timeout<\/p>\n<ul>\n<li>usage: <code>timeout<\/code>(<em>name<\/em>, <em>delay<\/em>)<br \/>\nsets a timeout to\u00a0<em>delay<\/em> seconds in the future: in <em>delay<\/em> seconds, a new synthetic event with the following fields will be injected:<\/p>\n<ul>\n<li><code>.timeout.regdate<\/code>: date at which the <code>timeout<\/code> call was issued<\/li>\n<li><code>.timeout.date<\/code>: date at which the timeout is triggered, should be equal (or slightly above) <code>.timeout.regdate<\/code>+<em>delay<\/em><\/li>\n<li><code>.timeout.name<\/code>: the name <em>name<\/em> of the timeout, as given as first argument to <code>timeout<\/code><\/li>\n<\/ul>\n<\/li>\n<li>returns: 1 (true)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The timeout module is an extension module. \u00a0Its purpose is to add new primitives to the Orchids language. As a preliminary warning, using the timeout module to kill useless Orchids threads is in general a bad idea, because Orchids is clever enough to kill them by itself. One may also think of using the timeout &hellip; <a href=\"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/?page_id=357\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">The timeout module<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-357","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=\/wp\/v2\/pages\/357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=357"}],"version-history":[{"count":4,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=\/wp\/v2\/pages\/357\/revisions"}],"predecessor-version":[{"id":718,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=\/wp\/v2\/pages\/357\/revisions\/718"}],"wp:attachment":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}