EVOLUTION-MANAGER
Edit File: create_loop.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Private event loops</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for create_loop {later}"><tr><td>create_loop {later}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Private event loops</h2> <h3>Description</h3> <p>Normally, later uses a global event loop for scheduling and running functions. However, in some cases, it is useful to create a <em>private</em> event loop to schedule and execute tasks without disturbing the global event loop. For example, you might have asynchronous code that queries a remote data source, but want to wait for a full back-and-forth communication to complete before continuing in your code – from the caller's perspective, it should behave like synchronous code, and not do anything with the global event loop (which could run code unrelated to your operation). To do this, you would run your asynchronous code using a private event loop. </p> <h3>Usage</h3> <pre> create_loop(parent = current_loop(), autorun = NULL) destroy_loop(loop) exists_loop(loop) current_loop() with_temp_loop(expr) with_loop(loop, expr) global_loop() </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>parent</code></td> <td> <p>The parent event loop for the one being created. Whenever the parent loop runs, this loop will also automatically run, without having to manually call <code><a href="run_now.html">run_now</a>()</code> on this loop. If <code>NULL</code>, then this loop will not have a parent event loop that automatically runs it; the only way to run this loop will be by calling <code><a href="run_now.html">run_now</a>()</code> on this loop.</p> </td></tr> <tr valign="top"><td><code>autorun</code></td> <td> <p>This exists only for backward compatibility. If set to <code>FALSE</code>, it is equivalent to using <code>parent=NULL</code>.</p> </td></tr> <tr valign="top"><td><code>loop</code></td> <td> <p>A handle to an event loop.</p> </td></tr> <tr valign="top"><td><code>expr</code></td> <td> <p>An expression to evaluate.</p> </td></tr> </table> <h3>Details</h3> <p><code>create_loop</code> creates and returns a handle to a private event loop, which is useful when for scheduling tasks when you do not want to interfere with the global event loop. </p> <p><code>destroy_loop</code> destroys a private event loop. </p> <p><code>exists_loop</code> reports whether an event loop exists – that is, that it has not been destroyed. </p> <p><code>current_loop</code> returns the currently-active event loop. Any calls to <code><a href="later.html">later</a>()</code> or <code><a href="run_now.html">run_now</a>()</code> will use the current loop by default. </p> <p><code>with_loop</code> evaluates an expression with a given event loop as the currently-active loop. </p> <p><code>with_temp_loop</code> creates an event loop, makes it the current loop, then evaluates the given expression. Afterwards, the new event loop is destroyed. </p> <p><code>global_loop</code> returns a handle to the global event loop. </p> <hr /><div style="text-align: center;">[Package <em>later</em> version 1.1.0.1 <a href="00Index.html">Index</a>]</div> </body></html>