2015-11-09 08:01:19 -08:00
<!DOCTYPE html>
< html >
< head >
< meta http-equiv = "Content-type" content = "text/html;charset=UTF-8" / >
< title > Scheduler Class – Wren< / title >
2020-06-05 22:25:23 +00:00
< script type = "application/javascript" src = "../../../prism.js" data-manual > < / script >
< script type = "application/javascript" src = "../../../wren.js" > < / script >
< link rel = "stylesheet" type = "text/css" href = "../../../prism.css" / >
< link rel = "stylesheet" type = "text/css" href = "../../../style.css" / >
2015-11-09 08:01:19 -08:00
< link href = '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro:400|Lato:400|Sanchez:400italic,400' rel = 'stylesheet' type = 'text/css' >
<!-- Tell mobile browsers we're optimized for them and they don't need to crop
the viewport. -->
< meta name = "viewport" content = "width=device-width, initial-scale=1, maximum-scale=1" / >
< / head >
< body id = "top" class = "module" >
< header >
< div class = "page" >
< div class = "main-column" >
2020-06-05 22:25:23 +00:00
< h1 > < a href = "../../../" > wren< / a > < / h1 >
2015-11-09 08:01:19 -08:00
< h2 > a classy little scripting language< / h2 >
< / div >
< / div >
< / header >
< div class = "page" >
< nav class = "big" >
2020-06-05 22:25:23 +00:00
< a href = "../../../" > < img src = "../../../wren.svg" class = "logo" > < / a >
2015-11-09 08:01:19 -08:00
< ul >
2020-06-05 22:25:23 +00:00
< li > < a href = "../../" > Back to Wren CLI< / a > < / li >
< li > < a href = "../" > Back to CLI Modules< / a > < / li >
< li > < a href = "./" > scheduler module< / a > < / li >
2015-11-09 08:01:19 -08:00
< / ul >
< section >
< h2 > scheduler classes< / h2 >
< ul >
< li > < a href = "scheduler.html" > Scheduler< / a > < / li >
< / ul >
< / section >
< / nav >
< nav class = "small" >
< table >
< tr >
2020-06-05 22:25:23 +00:00
< td > < a href = "../" > Back to CLI Modules< / a > < / td >
< td > < a href = "./" > scheduler module< / a > < / td >
2015-11-09 08:01:19 -08:00
< / tr >
< tr >
< td colspan = "2" > < h2 > scheduler classes< / h2 > < / td >
< / tr >
< tr >
< td >
< ul >
< li > < a href = "scheduler.html" > Scheduler< / a > < / li >
< / ul >
< / td >
< td >
< ul >
< / ul >
< / td >
< / tr >
< / table >
< / nav >
< main >
< h1 > Scheduler Class< / h1 >
2021-02-06 15:58:10 +00:00
< p > The Scheduler class maintains a list of fibers, to be started one after the other, when a signal to do so is received. The signal (a private method call) is typically transmitted by < em > long running< / em > methods in the File or Timer classes which suspend the current fiber so that Wren can carry out other tasks in the meantime.< / p >
< h2 > Static Method < a href = "#static-method" name = "static-method" class = "header-anchor" > #< / a > < / h2 >
< h3 > Scheduler.< strong > add< / strong > (callable) < a href = "#scheduler.add(callable)" name = "scheduler.add(callable)" class = "header-anchor" > #< / a > < / h3 >
< p > Adds a new fiber to the scheduler’ s fibers list. This fiber calls < code > callable< / code > and then transfers to the next fiber in the list, if there is one.< / p >
< p > < code > callable< / code > is a function or other object which has a call() method.< / p >
< pre class = "snippet" >
var a = 3
Scheduler.add {
a = a * a
}
Scheduler.add {
a = a + 1
}
System.print(a) // still 3
Timer.sleep(3000) // wait 3 seconds
System.print(a) // now 3 * 3 + 1 = 10
< / pre >
2015-11-09 08:01:19 -08:00
< / main >
< / div >
< footer >
< div class = "page" >
< div class = "main-column" >
< p > Wren lives
2019-02-06 02:52:27 +00:00
< a href = "https://github.com/wren-lang/wren" > on GitHub< / a >
2015-11-09 08:01:19 -08:00
— Made with ❤ by
< a href = "http://journal.stuffwithstuff.com/" > Bob Nystrom< / a > and
2020-06-12 17:15:45 +00:00
< a href = "https://github.com/wren-lang/wren/blob/main/AUTHORS" > friends< / a > .
2015-11-09 08:01:19 -08:00
< / p >
< div class = "main-column" >
< / div >
< / footer >
< / body >
< / html >