feat: add example scripts for argparse, bytes, dataset, html, markdown, uuid, wdantic, and web chat modules
Add comprehensive demo scripts showcasing the usage of multiple Wren modules including argument parsing, byte manipulation, in-memory dataset operations, HTML encoding/slugification, markdown-to-HTML conversion, UUID generation/validation, schema validation with wdantic, and a full web chat application with REST endpoints.
2026-01-24 23:40:22 +01:00
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title > scheduler - Wren-CLI Manual< / title >
< link rel = "stylesheet" href = "../css/style.css" >
< / head >
< body >
< button class = "mobile-menu-toggle" > Menu< / button >
< div class = "container" >
< aside class = "sidebar" >
< div class = "sidebar-header" >
< h1 > < a href = "../index.html" > Wren-CLI< / a > < / h1 >
< div class = "version" > v0.4.0< / div >
< / div >
< nav class = "sidebar-nav" >
< div class = "section" >
< span class = "section-title" > Getting Started< / span >
< ul >
< li > < a href = "../getting-started/index.html" > Overview< / a > < / li >
< li > < a href = "../getting-started/installation.html" > Installation< / a > < / li >
< li > < a href = "../getting-started/first-script.html" > First Script< / a > < / li >
< li > < a href = "../getting-started/repl.html" > Using the REPL< / a > < / li >
< / ul >
< / div >
< div class = "section" >
< span class = "section-title" > Language< / span >
< ul >
< li > < a href = "../language/index.html" > Syntax Overview< / a > < / li >
< li > < a href = "../language/classes.html" > Classes< / a > < / li >
< li > < a href = "../language/methods.html" > Methods< / a > < / li >
< li > < a href = "../language/control-flow.html" > Control Flow< / a > < / li >
< li > < a href = "../language/fibers.html" > Fibers< / a > < / li >
< li > < a href = "../language/modules.html" > Modules< / a > < / li >
< / ul >
< / div >
< div class = "section" >
< span class = "section-title" > API Reference< / span >
< ul >
< li > < a href = "index.html" > Overview< / a > < / li >
feat: add async/await keywords, Num/String extensions, and Jinja markdown example
Add `async` and `await` token support to the Wren compiler with scheduler resolution logic, extend `Num` with `e` constant, hyperbolic trig, base conversion, and new methods (`isZero`, `gcd`, `lcm`, `digits`, etc.), extend `String` with `lower`, `upper`, `capitalize`, `title`, and regenerate `wren_core.wren.inc`. Include `Makefile` for multi-platform builds, rewrite `README.md` with updated build instructions, and add `example/await_demo.wren` and `example/jinja_markdown.wren` demonstrating new features.
2026-01-25 04:58:39 +01:00
< li > < a href = "string.html" > String< / a > < / li >
< li > < a href = "number.html" > Num< / a > < / li >
feat: add example scripts for argparse, bytes, dataset, html, markdown, uuid, wdantic, and web chat modules
Add comprehensive demo scripts showcasing the usage of multiple Wren modules including argument parsing, byte manipulation, in-memory dataset operations, HTML encoding/slugification, markdown-to-HTML conversion, UUID generation/validation, schema validation with wdantic, and a full web chat application with REST endpoints.
2026-01-24 23:40:22 +01:00
< li > < a href = "http.html" > http< / a > < / li >
< li > < a href = "websocket.html" > websocket< / a > < / li >
< li > < a href = "tls.html" > tls< / a > < / li >
< li > < a href = "net.html" > net< / a > < / li >
< li > < a href = "dns.html" > dns< / a > < / li >
< li > < a href = "json.html" > json< / a > < / li >
< li > < a href = "base64.html" > base64< / a > < / li >
< li > < a href = "regex.html" > regex< / a > < / li >
< li > < a href = "jinja.html" > jinja< / a > < / li >
< li > < a href = "crypto.html" > crypto< / a > < / li >
< li > < a href = "os.html" > os< / a > < / li >
< li > < a href = "env.html" > env< / a > < / li >
< li > < a href = "signal.html" > signal< / a > < / li >
< li > < a href = "subprocess.html" > subprocess< / a > < / li >
< li > < a href = "sqlite.html" > sqlite< / a > < / li >
< li > < a href = "datetime.html" > datetime< / a > < / li >
< li > < a href = "timer.html" > timer< / a > < / li >
< li > < a href = "io.html" > io< / a > < / li >
feat: add async/await keywords, Num/String extensions, and Jinja markdown example
Add `async` and `await` token support to the Wren compiler with scheduler resolution logic, extend `Num` with `e` constant, hyperbolic trig, base conversion, and new methods (`isZero`, `gcd`, `lcm`, `digits`, etc.), extend `String` with `lower`, `upper`, `capitalize`, `title`, and regenerate `wren_core.wren.inc`. Include `Makefile` for multi-platform builds, rewrite `README.md` with updated build instructions, and add `example/await_demo.wren` and `example/jinja_markdown.wren` demonstrating new features.
2026-01-25 04:58:39 +01:00
< li > < a href = "pathlib.html" > pathlib< / a > < / li >
feat: add example scripts for argparse, bytes, dataset, html, markdown, uuid, wdantic, and web chat modules
Add comprehensive demo scripts showcasing the usage of multiple Wren modules including argument parsing, byte manipulation, in-memory dataset operations, HTML encoding/slugification, markdown-to-HTML conversion, UUID generation/validation, schema validation with wdantic, and a full web chat application with REST endpoints.
2026-01-24 23:40:22 +01:00
< li > < a href = "scheduler.html" class = "active" > scheduler< / a > < / li >
< li > < a href = "math.html" > math< / a > < / li >
< / ul >
< / div >
< div class = "section" >
< span class = "section-title" > Tutorials< / span >
< ul >
< li > < a href = "../tutorials/index.html" > Tutorial List< / a > < / li >
< / ul >
< / div >
< div class = "section" >
< span class = "section-title" > How-To Guides< / span >
< ul >
< li > < a href = "../howto/index.html" > How-To List< / a > < / li >
< / ul >
< / div >
< / nav >
< / aside >
< main class = "content" >
< nav class = "breadcrumb" >
< a href = "../index.html" > Home< / a >
< span class = "separator" > /< / span >
< a href = "index.html" > API Reference< / a >
< span class = "separator" > /< / span >
< span > scheduler< / span >
< / nav >
< article >
< h1 > scheduler< / h1 >
< p > The < code > scheduler< / code > module manages the async event loop and fiber scheduling. It is the foundation for all async operations in Wren-CLI.< / p >
< pre > < code > import "scheduler" for Scheduler< / code > < / pre >
< h2 > Scheduler Class< / h2 >
< div class = "class-header" >
< h3 > Scheduler< / h3 >
< p > Async fiber scheduler< / p >
< / div >
< h3 > Static Methods< / h3 >
< div class = "method-signature" >
< span class = "method-name" > Scheduler.await_< / span > (< span class = "param" > block< / span > ) → < span class = "type" > any< / span >
< / div >
< p > Suspends the current fiber until an async operation completes. Used internally by modules to implement async operations.< / p >
< ul class = "param-list" >
< li > < span class = "param-name" > block< / span > < span class = "param-type" > (Fn)< / span > - Block that initiates the async operation< / li >
< li > < span class = "returns" > Returns:< / span > Result of the async operation< / li >
< / ul >
< pre > < code > var result = Scheduler.await_ {
Timer.sleep_(1000, Fiber.current)
}< / code > < / pre >
< div class = "method-signature" >
< span class = "method-name" > Scheduler.resume_< / span > (< span class = "param" > fiber< / span > )
< / div >
< p > Resumes a suspended fiber. Used by native code to wake up fibers when async operations complete.< / p >
< div class = "method-signature" >
< span class = "method-name" > Scheduler.resume_< / span > (< span class = "param" > fiber< / span > , < span class = "param" > value< / span > )
< / div >
< p > Resumes a fiber with a result value.< / p >
< h2 > How Async Works< / h2 >
< p > Wren-CLI uses an event loop (libuv) for non-blocking I/O. Here is how async operations work:< / p >
< ol >
< li > A Wren fiber calls an async method (e.g., < code > Http.get< / code > )< / li >
< li > The method starts a native async operation and suspends the fiber< / li >
< li > The event loop continues processing other events< / li >
< li > When the operation completes, the fiber is resumed with the result< / li >
< / ol >
< h3 > Under the Hood< / h3 >
< pre > < code > // How Timer.sleep works internally
class Timer {
static sleep(ms) {
return Scheduler.await_ {
Timer.sleep_(ms, Fiber.current)
}
}
foreign static sleep_(ms, fiber)
}< / code > < / pre >
< h2 > Examples< / h2 >
< h3 > Sequential vs Parallel< / h3 >
< p > Operations are sequential by default:< / p >
< pre > < code > import "http" for Http
// These run one after another (sequential)
var r1 = Http.get("https://api.example.com/1")
var r2 = Http.get("https://api.example.com/2")
var r3 = Http.get("https://api.example.com/3")< / code > < / pre >
< p > For parallel operations, use multiple fibers:< / p >
< pre > < code > import "http" for Http
var fibers = [
Fiber.new { Http.get("https://api.example.com/1") },
Fiber.new { Http.get("https://api.example.com/2") },
Fiber.new { Http.get("https://api.example.com/3") }
]
// Start all fibers
for (f in fibers) f.call()
// Results are already available when fibers complete< / code > < / pre >
< div class = "admonition note" >
< div class = "admonition-title" > Note< / div >
< p > The scheduler is used internally by modules. Most user code does not need to interact with it directly. Use higher-level modules like < code > timer< / code > , < code > http< / code > , and < code > io< / code > instead.< / p >
< / div >
< div class = "admonition tip" >
< div class = "admonition-title" > Tip< / div >
< p > Async operations in Wren-CLI are cooperative, not preemptive. A fiber runs until it explicitly yields or calls an async operation.< / p >
< / div >
< / article >
< footer class = "page-footer" >
feat: add async/await keywords, Num/String extensions, and Jinja markdown example
Add `async` and `await` token support to the Wren compiler with scheduler resolution logic, extend `Num` with `e` constant, hyperbolic trig, base conversion, and new methods (`isZero`, `gcd`, `lcm`, `digits`, etc.), extend `String` with `lower`, `upper`, `capitalize`, `title`, and regenerate `wren_core.wren.inc`. Include `Makefile` for multi-platform builds, rewrite `README.md` with updated build instructions, and add `example/await_demo.wren` and `example/jinja_markdown.wren` demonstrating new features.
2026-01-25 04:58:39 +01:00
< a href = "pathlib.html" class = "prev" > pathlib< / a >
feat: add example scripts for argparse, bytes, dataset, html, markdown, uuid, wdantic, and web chat modules
Add comprehensive demo scripts showcasing the usage of multiple Wren modules including argument parsing, byte manipulation, in-memory dataset operations, HTML encoding/slugification, markdown-to-HTML conversion, UUID generation/validation, schema validation with wdantic, and a full web chat application with REST endpoints.
2026-01-24 23:40:22 +01:00
< a href = "math.html" class = "next" > math< / a >
< / footer >
< / main >
< / div >
< script src = "../js/main.js" > < / script >
< / body >
< / html >