3756 lines
111 KiB
HTML
3756 lines
111 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>
|
|
Class: Concurrent::Promises::Future
|
|
|
|
— Concurrent Ruby
|
|
|
|
</title>
|
|
|
|
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
|
|
|
|
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
|
|
|
|
<script type="text/javascript" charset="utf-8">
|
|
pathId = "Concurrent::Promises::Future";
|
|
relpath = '../../';
|
|
</script>
|
|
|
|
|
|
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
|
|
|
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
|
|
|
|
|
</head>
|
|
<body>
|
|
<div class="nav_wrap">
|
|
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
|
<div id="resizer"></div>
|
|
</div>
|
|
|
|
<div id="main" tabindex="-1">
|
|
<div id="header">
|
|
<div id="menu">
|
|
|
|
<a href="../../_index.html">Index (F)</a> »
|
|
<span class='title'><span class='object_link'><a href="../../Concurrent.html" title="Concurrent (module)">Concurrent</a></span></span> » <span class='title'><span class='object_link'><a href="../Promises.html" title="Concurrent::Promises (module)">Promises</a></span></span>
|
|
»
|
|
<span class="title">Future</span>
|
|
|
|
</div>
|
|
|
|
<div id="search">
|
|
|
|
<a class="full_list_link" id="class_list_link"
|
|
href="../../class_list.html">
|
|
|
|
<svg width="24" height="24">
|
|
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
|
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
|
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
|
</svg>
|
|
</a>
|
|
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>
|
|
|
|
<div id="content"><h1>Class: Concurrent::Promises::Future
|
|
|
|
|
|
|
|
</h1>
|
|
<div class="box_info">
|
|
|
|
<dl>
|
|
<dt>Inherits:</dt>
|
|
<dd>
|
|
<span class="inheritName"><span class='object_link'><a href="AbstractEventFuture.html" title="Concurrent::Promises::AbstractEventFuture (class)">AbstractEventFuture</a></span></span>
|
|
|
|
<ul class="fullTree">
|
|
<li>Object</li>
|
|
|
|
<li class="next"><span class='object_link'><a href="../Synchronization/Object.html" title="Concurrent::Synchronization::Object (class)">Synchronization::Object</a></span></li>
|
|
|
|
<li class="next"><span class='object_link'><a href="AbstractEventFuture.html" title="Concurrent::Promises::AbstractEventFuture (class)">AbstractEventFuture</a></span></li>
|
|
|
|
<li class="next">Concurrent::Promises::Future</li>
|
|
|
|
</ul>
|
|
<a href="#" class="inheritanceTree">show all</a>
|
|
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dl>
|
|
<dt>Includes:</dt>
|
|
<dd><span class='object_link'><a href="Future/ActorIntegration.html" title="Concurrent::Promises::Future::ActorIntegration (module)">ActorIntegration</a></span>, <span class='object_link'><a href="Future/FlatShortcuts.html" title="Concurrent::Promises::Future::FlatShortcuts (module)">FlatShortcuts</a></span>, <span class='object_link'><a href="Future/NewChannelIntegration.html" title="Concurrent::Promises::Future::NewChannelIntegration (module)">NewChannelIntegration</a></span>, <span class='object_link'><a href="Future/ThrottleIntegration.html" title="Concurrent::Promises::Future::ThrottleIntegration (module)">ThrottleIntegration</a></span></dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dl>
|
|
<dt>Defined in:</dt>
|
|
<dd>lib/concurrent/promises.rb<span class="defines">,<br />
|
|
lib-edge/concurrent/edge/promises.rb,<br /> lib-edge/concurrent/edge/promises.rb,<br /> lib-edge/concurrent/edge/throttle.rb,<br /> lib-edge/concurrent/edge/old_channel_integration.rb</span>
|
|
</dd>
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
<h2>Overview</h2><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Represents a value which will become available in future. May reject with a reason instead,
|
|
e.g. when the tasks raises an exception.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
|
|
</div><div id="subclasses">
|
|
<h2>Direct Known Subclasses</h2>
|
|
<p class="children"><span class='object_link'><a href="ResolvableFuture.html" title="Concurrent::Promises::ResolvableFuture (class)">ResolvableFuture</a></span></p>
|
|
</div>
|
|
<h2>Defined Under Namespace</h2>
|
|
<p class="children">
|
|
|
|
|
|
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Future/ActorIntegration.html" title="Concurrent::Promises::Future::ActorIntegration (module)">ActorIntegration</a></span>, <span class='object_link'><a href="Future/FlatShortcuts.html" title="Concurrent::Promises::Future::FlatShortcuts (module)">FlatShortcuts</a></span>, <span class='object_link'><a href="Future/NewChannelIntegration.html" title="Concurrent::Promises::Future::NewChannelIntegration (module)">NewChannelIntegration</a></span>, <span class='object_link'><a href="Future/ThrottleIntegration.html" title="Concurrent::Promises::Future::ThrottleIntegration (module)">ThrottleIntegration</a></span>
|
|
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2>
|
|
Instance Method Summary
|
|
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
</h2>
|
|
|
|
<ul class="summary">
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#any-instance_method" title="#any (instance method)">#<strong>any</strong>(event_or_future) ⇒ Future </a>
|
|
|
|
|
|
|
|
(also: #|)
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Creates a new event which will be resolved when the first of receiver, <code>event_or_future</code> resolves.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#delay-instance_method" title="#delay (instance method)">#<strong>delay</strong> ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Creates new future dependent on receiver which will not evaluate until touched, see <span class='object_link'><a href="AbstractEventFuture.html#touch-instance_method" title="Concurrent::Promises::AbstractEventFuture#touch (method)">AbstractEventFuture#touch</a></span>.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#exception-instance_method" title="#exception (instance method)">#<strong>exception</strong>(*args) ⇒ Exception </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Allows rejected Future to be risen with <code>raise</code> method.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#flat_event-instance_method" title="#flat_event (instance method)">#<strong>flat_event</strong> ⇒ Event </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Creates new event which will be resolved when the returned event by receiver is.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#flat_future-instance_method" title="#flat_future (instance method)">#<strong>flat_future</strong>(level = 1) ⇒ Future </a>
|
|
|
|
|
|
|
|
(also: #flat)
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Creates new future which will have result of the future returned by receiver.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#fulfilled%3F-instance_method" title="#fulfilled? (instance method)">#<strong>fulfilled?</strong> ⇒ Boolean </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Is it in fulfilled state?.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#on_fulfillment-instance_method" title="#on_fulfillment (instance method)">#<strong>on_fulfillment</strong>(*args, &callback) ⇒ self </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Shortcut of <span class='object_link'><a href="#on_fulfillment_using-instance_method" title="Concurrent::Promises::Future#on_fulfillment_using (method)">#on_fulfillment_using</a></span> with default <code>:io</code> executor supplied.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#on_fulfillment!-instance_method" title="#on_fulfillment! (instance method)">#<strong>on_fulfillment!</strong>(*args) {|value, *args| ... } ⇒ self </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Stores the callback to be executed synchronously on resolving thread after it is fulfilled.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#on_fulfillment_using-instance_method" title="#on_fulfillment_using (instance method)">#<strong>on_fulfillment_using</strong>(executor, *args) {|value, *args| ... } ⇒ self </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Stores the callback to be executed asynchronously on executor after it is fulfilled.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#on_rejection-instance_method" title="#on_rejection (instance method)">#<strong>on_rejection</strong>(*args, &callback) ⇒ self </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Shortcut of <span class='object_link'><a href="#on_rejection_using-instance_method" title="Concurrent::Promises::Future#on_rejection_using (method)">#on_rejection_using</a></span> with default <code>:io</code> executor supplied.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#on_rejection!-instance_method" title="#on_rejection! (instance method)">#<strong>on_rejection!</strong>(*args) {|reason, *args| ... } ⇒ self </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Stores the callback to be executed synchronously on resolving thread after it is rejected.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#on_rejection_using-instance_method" title="#on_rejection_using (instance method)">#<strong>on_rejection_using</strong>(executor, *args) {|reason, *args| ... } ⇒ self </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Stores the callback to be executed asynchronously on executor after it is rejected.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#reason-instance_method" title="#reason (instance method)">#<strong>reason</strong>(timeout = nil) ⇒ Exception<sup>?</sup> </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Returns reason of future's rejection.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#rejected%3F-instance_method" title="#rejected? (instance method)">#<strong>rejected?</strong> ⇒ Boolean </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Is it in rejected state?.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#rescue-instance_method" title="#rescue (instance method)">#<strong>rescue</strong>(*args, &task) ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Shortcut of <span class='object_link'><a href="#rescue_on-instance_method" title="Concurrent::Promises::Future#rescue_on (method)">#rescue_on</a></span> with default <code>:io</code> executor supplied.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#rescue_on-instance_method" title="#rescue_on (instance method)">#<strong>rescue_on</strong>(executor, *args) {|reason, *args| ... } ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Chains the task to be executed asynchronously on executor after it rejects.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#rescue_throttled_by-instance_method" title="#rescue_throttled_by (instance method)">#<strong>rescue_throttled_by</strong>(throttle, *args, &block) ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
<span class="note title not_defined_here">
|
|
included
|
|
from <span class='object_link'><a href="Future/ThrottleIntegration.html#rescue_throttled_by-instance_method" title="Concurrent::Promises::Future::ThrottleIntegration#rescue_throttled_by (method)">ThrottleIntegration</a></span>
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Behaves as <span class='object_link'><a href="#rescue-instance_method" title="Concurrent::Promises::Future#rescue (method)">#rescue</a></span> but the it is throttled.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#result-instance_method" title="#result (instance method)">#<strong>result</strong>(timeout = nil) ⇒ Array(Boolean, Object, Exception)<sup>?</sup> </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Returns triplet fulfilled?, value, reason.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#run-instance_method" title="#run (instance method)">#<strong>run</strong> ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Allows to use futures as green threads.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#schedule-instance_method" title="#schedule (instance method)">#<strong>schedule</strong>(intended_time) ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Creates new event dependent on receiver scheduled to execute on/in intended_time.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#then-instance_method" title="#then (instance method)">#<strong>then</strong>(*args, &task) ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Shortcut of <span class='object_link'><a href="#then_on-instance_method" title="Concurrent::Promises::Future#then_on (method)">#then_on</a></span> with default <code>:io</code> executor supplied.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#then_ask-instance_method" title="#then_ask (instance method)">#<strong>then_ask</strong>(actor) ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
<span class="note title not_defined_here">
|
|
included
|
|
from <span class='object_link'><a href="Future/ActorIntegration.html#then_ask-instance_method" title="Concurrent::Promises::Future::ActorIntegration#then_ask (method)">ActorIntegration</a></span>
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Asks the actor with its value.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#then_flat_event-instance_method" title="#then_flat_event (instance method)">#<strong>then_flat_event</strong>(*args, &block) ⇒ Event </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
<span class="note title not_defined_here">
|
|
included
|
|
from <span class='object_link'><a href="Future/FlatShortcuts.html#then_flat_event-instance_method" title="Concurrent::Promises::Future::FlatShortcuts#then_flat_event (method)">FlatShortcuts</a></span>
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#then_flat_event_on-instance_method" title="#then_flat_event_on (instance method)">#<strong>then_flat_event_on</strong>(executor, *args, &block) ⇒ Event </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
<span class="note title not_defined_here">
|
|
included
|
|
from <span class='object_link'><a href="Future/FlatShortcuts.html#then_flat_event_on-instance_method" title="Concurrent::Promises::Future::FlatShortcuts#then_flat_event_on (method)">FlatShortcuts</a></span>
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#then_flat_future-instance_method" title="#then_flat_future (instance method)">#<strong>then_flat_future</strong>(*args, &block) ⇒ Future </a>
|
|
|
|
|
|
|
|
(also: #then_flat)
|
|
|
|
</span>
|
|
|
|
<span class="note title not_defined_here">
|
|
included
|
|
from <span class='object_link'><a href="Future/FlatShortcuts.html#then_flat_future-instance_method" title="Concurrent::Promises::Future::FlatShortcuts#then_flat_future (method)">FlatShortcuts</a></span>
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#then_flat_future_on-instance_method" title="#then_flat_future_on (instance method)">#<strong>then_flat_future_on</strong>(executor, *args, &block) ⇒ Future </a>
|
|
|
|
|
|
|
|
(also: #then_flat_on)
|
|
|
|
</span>
|
|
|
|
<span class="note title not_defined_here">
|
|
included
|
|
from <span class='object_link'><a href="Future/FlatShortcuts.html#then_flat_future_on-instance_method" title="Concurrent::Promises::Future::FlatShortcuts#then_flat_future_on (method)">FlatShortcuts</a></span>
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#then_on-instance_method" title="#then_on (instance method)">#<strong>then_on</strong>(executor, *args) {|value, *args| ... } ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Chains the task to be executed asynchronously on executor after it fulfills.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#then_push_channel-instance_method" title="#then_push_channel (instance method)">#<strong>then_push_channel</strong>(channel) ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
<span class="note title not_defined_here">
|
|
included
|
|
from <span class='object_link'><a href="Future/NewChannelIntegration.html#then_push_channel-instance_method" title="Concurrent::Promises::Future::NewChannelIntegration#then_push_channel (method)">NewChannelIntegration</a></span>
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>A future which is fulfilled after the message is pushed to the channel.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#then_throttled_by-instance_method" title="#then_throttled_by (instance method)">#<strong>then_throttled_by</strong>(throttle, *args, &block) ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
<span class="note title not_defined_here">
|
|
included
|
|
from <span class='object_link'><a href="Future/ThrottleIntegration.html#then_throttled_by-instance_method" title="Concurrent::Promises::Future::ThrottleIntegration#then_throttled_by (method)">ThrottleIntegration</a></span>
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Behaves as <span class='object_link'><a href="#then-instance_method" title="Concurrent::Promises::Future#then (method)">#then</a></span> but the it is throttled.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#to_event-instance_method" title="#to_event (instance method)">#<strong>to_event</strong> ⇒ Event </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Converts future to event which is resolved when future is resolved by fulfillment or rejection.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#to_future-instance_method" title="#to_future (instance method)">#<strong>to_future</strong> ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Returns self, since this is a future.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#value-instance_method" title="#value (instance method)">#<strong>value</strong>(timeout = nil) ⇒ Object<sup>?</sup> </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Return value of the future.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#value!-instance_method" title="#value! (instance method)">#<strong>value!</strong>(timeout = nil) ⇒ Object<sup>?</sup> </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Return value of the future.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#wait!-instance_method" title="#wait! (instance method)">#<strong>wait!</strong>(timeout = nil) ⇒ Future, true, false </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Wait (block the Thread) until receiver is <span class='object_link'><a href="AbstractEventFuture.html#resolved%3F-instance_method" title="Concurrent::Promises::AbstractEventFuture#resolved? (method)">AbstractEventFuture#resolved?</a></span>.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#with_default_executor-instance_method" title="#with_default_executor (instance method)">#<strong>with_default_executor</strong>(executor) ⇒ Future </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Crates new object with same class with the executor set as its new default executor.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#zip-instance_method" title="#zip (instance method)">#<strong>zip</strong>(other) ⇒ Future </a>
|
|
|
|
|
|
|
|
(also: #&)
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Creates a new event or a future which will be resolved when receiver and other are.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div id="instance_method_details" class="method_details_list">
|
|
<h2>Instance Method Details</h2>
|
|
|
|
|
|
<div class="method_details first">
|
|
<h3 class="signature first" id="any-instance_method">
|
|
|
|
#<strong>any</strong>(event_or_future) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
<span class="aliases">Also known as:
|
|
<span class="names"><span id='|-instance_method'>|</span></span>
|
|
</span>
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Creates a new event which will be resolved when the first of receiver, <code>event_or_future</code>
|
|
resolves. Returning future will have value nil if event_or_future is event and resolves
|
|
first.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1023
|
|
1024
|
|
1025</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1023</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_any'>any</span><span class='lparen'>(</span><span class='id identifier rubyid_event_or_future'>event_or_future</span><span class='rparen'>)</span>
|
|
<span class='const'>AnyResolvedFuturePromise</span><span class='period'>.</span><span class='id identifier rubyid_new_blocked_by2'>new_blocked_by2</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_event_or_future'>event_or_future</span><span class='comma'>,</span> <span class='ivar'>@DefaultExecutor</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_future'>future</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="delay-instance_method">
|
|
|
|
#<strong>delay</strong> ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Creates new future dependent on receiver which will not evaluate until touched, see <span class='object_link'><a href="AbstractEventFuture.html#touch-instance_method" title="Concurrent::Promises::AbstractEventFuture#touch (method)">AbstractEventFuture#touch</a></span>.
|
|
In other words, it inserts delay into the chain of Futures making rest of it lazy evaluated.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1033
|
|
1034
|
|
1035
|
|
1036</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1033</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_delay'>delay</span>
|
|
<span class='id identifier rubyid_event'>event</span> <span class='op'>=</span> <span class='const'>DelayPromise</span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Synchronization/Object.html#new-class_method" title="Concurrent::Synchronization::Object.new (method)">new</a></span></span><span class='lparen'>(</span><span class='ivar'>@DefaultExecutor</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_event'>event</span>
|
|
<span class='const'>ZipFutureEventPromise</span><span class='period'>.</span><span class='id identifier rubyid_new_blocked_by2'>new_blocked_by2</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_event'>event</span><span class='comma'>,</span> <span class='ivar'>@DefaultExecutor</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_future'>future</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="exception-instance_method">
|
|
|
|
#<strong>exception</strong>(*args) ⇒ <tt>Exception</tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Allows rejected Future to be risen with <code>raise</code> method.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<div class="examples">
|
|
<p class="tag_title">Examples:</p>
|
|
|
|
|
|
<pre class="example code"><code><span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Promises.html" title="Concurrent::Promises (module)">Promises</a></span></span><span class='period'>.</span><span class='id identifier rubyid_rejected_future'><span class='object_link'><a href="FactoryMethods.html#rejected_future-instance_method" title="Concurrent::Promises::FactoryMethods#rejected_future (method)">rejected_future</a></span></span><span class='lparen'>(</span><span class='const'>StandardError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>boom</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rparen'>)</span></code></pre>
|
|
|
|
</div>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Exception</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Raises:</p>
|
|
<ul class="raise">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>StandardError</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>when raising not rejected future</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
956
|
|
957
|
|
958
|
|
959
|
|
960
|
|
961
|
|
962
|
|
963
|
|
964
|
|
965
|
|
966
|
|
967
|
|
968</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 956</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_exception'>exception</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../../Concurrent.html" title="Concurrent (module)">Concurrent</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Concurrent.html#Error-constant" title="Concurrent::Error (constant)">Error</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>it is not rejected</span><span class='tstring_end'>'</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_rejected?'>rejected?</span>
|
|
<span class='id identifier rubyid_reason'>reason</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Array.html" title="Concurrent::Array (class)">Array</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_internal_state'>internal_state</span><span class='period'>.</span><span class='id identifier rubyid_reason'>reason</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span>
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_reason'>reason</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>></span> <span class='int'>1</span>
|
|
<span class='id identifier rubyid_ex'>ex</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../Concurrent.html" title="Concurrent (module)">Concurrent</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../MultipleErrors.html" title="Concurrent::MultipleErrors (class)">MultipleErrors</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../MultipleErrors.html#initialize-instance_method" title="Concurrent::MultipleErrors#initialize (method)">new</a></span></span> <span class='id identifier rubyid_reason'>reason</span>
|
|
<span class='id identifier rubyid_ex'>ex</span><span class='period'>.</span><span class='id identifier rubyid_set_backtrace'>set_backtrace</span><span class='lparen'>(</span><span class='id identifier rubyid_caller'>caller</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_ex'>ex</span>
|
|
<span class='kw'>else</span>
|
|
<span class='id identifier rubyid_ex'>ex</span> <span class='op'>=</span> <span class='id identifier rubyid_reason'>reason</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_clone'>clone</span><span class='period'>.</span><span class='id identifier rubyid_exception'>exception</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_ex'>ex</span><span class='period'>.</span><span class='id identifier rubyid_set_backtrace'>set_backtrace</span> <span class='const'><span class='object_link'><a href="../Array.html" title="Concurrent::Array (class)">Array</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_ex'>ex</span><span class='period'>.</span><span class='id identifier rubyid_backtrace'>backtrace</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid_caller'>caller</span>
|
|
<span class='id identifier rubyid_ex'>ex</span>
|
|
<span class='kw'>end</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="flat_event-instance_method">
|
|
|
|
#<strong>flat_event</strong> ⇒ <tt><span class='object_link'><a href="Event.html" title="Concurrent::Promises::Event (class)">Event</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Creates new event which will be resolved when the returned event by receiver is.
|
|
Be careful if the receiver rejects it will just resolve since Event does not hold reason.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="Event.html" title="Concurrent::Promises::Event (class)">Event</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1068
|
|
1069
|
|
1070</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1068</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_flat_event'>flat_event</span>
|
|
<span class='const'>FlatEventPromise</span><span class='period'>.</span><span class='id identifier rubyid_new_blocked_by1'>new_blocked_by1</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='ivar'>@DefaultExecutor</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_event'>event</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="flat_future-instance_method">
|
|
|
|
#<strong>flat_future</strong>(level = 1) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
<span class="aliases">Also known as:
|
|
<span class="names"><span id='flat-instance_method'>flat</span></span>
|
|
</span>
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Creates new future which will have result of the future returned by receiver. If receiver
|
|
rejects it will have its rejection.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>level</span>
|
|
|
|
|
|
<span class='type'>(<tt>Integer</tt>)</span>
|
|
|
|
|
|
<em class="default">(defaults to: <tt>1</tt>)</em>
|
|
|
|
|
|
—
|
|
<div class='inline'><p>how many levels of futures should flatten</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1058
|
|
1059
|
|
1060</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1058</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_flat_future'>flat_future</span><span class='lparen'>(</span><span class='id identifier rubyid_level'>level</span> <span class='op'>=</span> <span class='int'>1</span><span class='rparen'>)</span>
|
|
<span class='const'>FlatFuturePromise</span><span class='period'>.</span><span class='id identifier rubyid_new_blocked_by1'>new_blocked_by1</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_level'>level</span><span class='comma'>,</span> <span class='ivar'>@DefaultExecutor</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_future'>future</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="fulfilled?-instance_method">
|
|
|
|
#<strong>fulfilled?</strong> ⇒ <tt>Boolean</tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Is it in fulfilled state?</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Boolean</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
886
|
|
887
|
|
888
|
|
889</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 886</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_fulfilled?'>fulfilled?</span>
|
|
<span class='id identifier rubyid_state'>state</span> <span class='op'>=</span> <span class='id identifier rubyid_internal_state'>internal_state</span>
|
|
<span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_resolved?'>resolved?</span> <span class='op'>&&</span> <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_fulfilled?'>fulfilled?</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="on_fulfillment-instance_method">
|
|
|
|
#<strong>on_fulfillment</strong>(*args, &callback) ⇒ <tt>self</tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Shortcut of <span class='object_link'><a href="#on_fulfillment_using-instance_method" title="Concurrent::Promises::Future#on_fulfillment_using (method)">#on_fulfillment_using</a></span> with default <code>:io</code> executor supplied.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>self</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">See Also:</p>
|
|
<ul class="see">
|
|
|
|
<li><span class='object_link'><a href="#on_fulfillment_using-instance_method" title="Concurrent::Promises::Future#on_fulfillment_using (method)">#on_fulfillment_using</a></span></li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1074
|
|
1075
|
|
1076</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1074</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_on_fulfillment'>on_fulfillment</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_callback'>callback</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_on_fulfillment_using'>on_fulfillment_using</span> <span class='ivar'>@DefaultExecutor</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_callback'>callback</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="on_fulfillment!-instance_method">
|
|
|
|
#<strong>on_fulfillment!</strong>(*args) {|value, *args| ... } ⇒ <tt>self</tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Stores the callback to be executed synchronously on resolving thread after it is
|
|
fulfilled. Does nothing on rejection.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>args</span>
|
|
|
|
|
|
<span class='type'>(<tt>Object</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>arguments which are passed to the task when it's executed.
|
|
(It might be prepended with other arguments, see the @yeild section).</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Yields:</p>
|
|
<ul class="yield">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="#value-instance_method" title="Concurrent::Promises::Future#value (method)">value</a></span></tt>, <tt>*args</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>to the callback.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Yield Returns:</p>
|
|
<ul class="yieldreturn">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'></span>
|
|
|
|
|
|
|
|
|
|
<div class='inline'><p>is forgotten.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>self</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1085
|
|
1086
|
|
1087</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1085</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_on_fulfillment!'>on_fulfillment!</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_callback'>callback</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_add_callback'>add_callback</span> <span class='symbol'>:callback_on_fulfillment</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_callback'>callback</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="on_fulfillment_using-instance_method">
|
|
|
|
#<strong>on_fulfillment_using</strong>(executor, *args) {|value, *args| ... } ⇒ <tt>self</tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Stores the callback to be executed asynchronously on executor after it is
|
|
fulfilled. Does nothing on rejection.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>executor</span>
|
|
|
|
|
|
<span class='type'>(<tt>Executor</tt>, <tt>:io</tt>, <tt>:fast</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>Instance of an executor or a name of the
|
|
global executor. The task is executed on it, default executor remains unchanged.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<span class='name'>args</span>
|
|
|
|
|
|
<span class='type'>(<tt>Object</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>arguments which are passed to the task when it's executed.
|
|
(It might be prepended with other arguments, see the @yeild section).</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Yields:</p>
|
|
<ul class="yield">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="#value-instance_method" title="Concurrent::Promises::Future#value (method)">value</a></span></tt>, <tt>*args</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>to the callback.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Yield Returns:</p>
|
|
<ul class="yieldreturn">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'></span>
|
|
|
|
|
|
|
|
|
|
<div class='inline'><p>is forgotten.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>self</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1097
|
|
1098
|
|
1099</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1097</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_on_fulfillment_using'>on_fulfillment_using</span><span class='lparen'>(</span><span class='id identifier rubyid_executor'>executor</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_callback'>callback</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_add_callback'>add_callback</span> <span class='symbol'>:async_callback_on_fulfillment</span><span class='comma'>,</span> <span class='id identifier rubyid_executor'>executor</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_callback'>callback</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="on_rejection-instance_method">
|
|
|
|
#<strong>on_rejection</strong>(*args, &callback) ⇒ <tt>self</tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Shortcut of <span class='object_link'><a href="#on_rejection_using-instance_method" title="Concurrent::Promises::Future#on_rejection_using (method)">#on_rejection_using</a></span> with default <code>:io</code> executor supplied.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>self</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">See Also:</p>
|
|
<ul class="see">
|
|
|
|
<li><span class='object_link'><a href="#on_rejection_using-instance_method" title="Concurrent::Promises::Future#on_rejection_using (method)">#on_rejection_using</a></span></li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1103
|
|
1104
|
|
1105</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1103</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_on_rejection'>on_rejection</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_callback'>callback</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_on_rejection_using'>on_rejection_using</span> <span class='ivar'>@DefaultExecutor</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_callback'>callback</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="on_rejection!-instance_method">
|
|
|
|
#<strong>on_rejection!</strong>(*args) {|reason, *args| ... } ⇒ <tt>self</tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Stores the callback to be executed synchronously on resolving thread after it is
|
|
rejected. Does nothing on fulfillment.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>args</span>
|
|
|
|
|
|
<span class='type'>(<tt>Object</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>arguments which are passed to the task when it's executed.
|
|
(It might be prepended with other arguments, see the @yeild section).</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Yields:</p>
|
|
<ul class="yield">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="#reason-instance_method" title="Concurrent::Promises::Future#reason (method)">reason</a></span></tt>, <tt>*args</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>to the callback.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Yield Returns:</p>
|
|
<ul class="yieldreturn">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'></span>
|
|
|
|
|
|
|
|
|
|
<div class='inline'><p>is forgotten.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>self</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1114
|
|
1115
|
|
1116</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1114</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_on_rejection!'>on_rejection!</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_callback'>callback</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_add_callback'>add_callback</span> <span class='symbol'>:callback_on_rejection</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_callback'>callback</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="on_rejection_using-instance_method">
|
|
|
|
#<strong>on_rejection_using</strong>(executor, *args) {|reason, *args| ... } ⇒ <tt>self</tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Stores the callback to be executed asynchronously on executor after it is
|
|
rejected. Does nothing on fulfillment.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>executor</span>
|
|
|
|
|
|
<span class='type'>(<tt>Executor</tt>, <tt>:io</tt>, <tt>:fast</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>Instance of an executor or a name of the
|
|
global executor. The task is executed on it, default executor remains unchanged.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<span class='name'>args</span>
|
|
|
|
|
|
<span class='type'>(<tt>Object</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>arguments which are passed to the task when it's executed.
|
|
(It might be prepended with other arguments, see the @yeild section).</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Yields:</p>
|
|
<ul class="yield">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="#reason-instance_method" title="Concurrent::Promises::Future#reason (method)">reason</a></span></tt>, <tt>*args</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>to the callback.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Yield Returns:</p>
|
|
<ul class="yieldreturn">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'></span>
|
|
|
|
|
|
|
|
|
|
<div class='inline'><p>is forgotten.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>self</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1126
|
|
1127
|
|
1128</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1126</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_on_rejection_using'>on_rejection_using</span><span class='lparen'>(</span><span class='id identifier rubyid_executor'>executor</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_callback'>callback</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_add_callback'>add_callback</span> <span class='symbol'>:async_callback_on_rejection</span><span class='comma'>,</span> <span class='id identifier rubyid_executor'>executor</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_callback'>callback</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="reason-instance_method">
|
|
|
|
#<strong>reason</strong>(timeout = nil) ⇒ <tt>Exception</tt><sup>?</sup>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<div class="note notetag">
|
|
<strong>Note:</strong>
|
|
<div class='inline'><p>This function potentially blocks current thread until the Future is resolved.
|
|
Be careful it can deadlock. Try to chain instead.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="note notetag">
|
|
<strong>Note:</strong>
|
|
<div class='inline'><p>Make sure returned <code>nil</code> is not confused with timeout, no value when rejected,
|
|
no reason when fulfilled, etc.
|
|
Use more exact methods if needed, like <span class='object_link'><a href="AbstractEventFuture.html#wait-instance_method" title="Concurrent::Promises::AbstractEventFuture#wait (method)">AbstractEventFuture#wait</a></span>, <span class='object_link'><a href="#value!-instance_method" title="Concurrent::Promises::Future#value! (method)">#value!</a></span>, <span class='object_link'><a href="#result-instance_method" title="Concurrent::Promises::Future#result (method)">#result</a></span>, etc.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<p>Returns reason of future's rejection.
|
|
Calls <span class='object_link'><a href="AbstractEventFuture.html#touch-instance_method" title="Concurrent::Promises::AbstractEventFuture#touch (method)">AbstractEventFuture#touch</a></span>.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>timeout</span>
|
|
|
|
|
|
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
|
|
|
|
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
|
|
|
|
—
|
|
<div class='inline'><p>the maximum time in second to wait.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Exception</tt>, <tt>nil</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>nil on timeout or fulfillment.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
922
|
|
923
|
|
924</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 922</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_reason'>reason</span><span class='lparen'>(</span><span class='id identifier rubyid_timeout'>timeout</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_internal_state'>internal_state</span><span class='period'>.</span><span class='id identifier rubyid_reason'>reason</span> <span class='kw'>if</span> <span class='id identifier rubyid_wait_until_resolved'>wait_until_resolved</span> <span class='id identifier rubyid_timeout'>timeout</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="rejected?-instance_method">
|
|
|
|
#<strong>rejected?</strong> ⇒ <tt>Boolean</tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Is it in rejected state?</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Boolean</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
893
|
|
894
|
|
895
|
|
896</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 893</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_rejected?'>rejected?</span>
|
|
<span class='id identifier rubyid_state'>state</span> <span class='op'>=</span> <span class='id identifier rubyid_internal_state'>internal_state</span>
|
|
<span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_resolved?'>resolved?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_fulfilled?'>fulfilled?</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="rescue-instance_method">
|
|
|
|
#<strong>rescue</strong>(*args, &task) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Shortcut of <span class='object_link'><a href="#rescue_on-instance_method" title="Concurrent::Promises::Future#rescue_on (method)">#rescue_on</a></span> with default <code>:io</code> executor supplied.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">See Also:</p>
|
|
<ul class="see">
|
|
|
|
<li><span class='object_link'><a href="#rescue_on-instance_method" title="Concurrent::Promises::Future#rescue_on (method)">#rescue_on</a></span></li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
990
|
|
991
|
|
992</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 990</span>
|
|
|
|
<span class='kw'>def</span> <span class='kw'>rescue</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_task'>task</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_rescue_on'>rescue_on</span> <span class='ivar'>@DefaultExecutor</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_task'>task</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="rescue_on-instance_method">
|
|
|
|
#<strong>rescue_on</strong>(executor, *args) {|reason, *args| ... } ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Chains the task to be executed asynchronously on executor after it rejects. Does not run
|
|
the task if it fulfills. It will resolve though, triggering any dependent futures.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>executor</span>
|
|
|
|
|
|
<span class='type'>(<tt>Executor</tt>, <tt>:io</tt>, <tt>:fast</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>Instance of an executor or a name of the
|
|
global executor. The task is executed on it, default executor remains unchanged.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<span class='name'>args</span>
|
|
|
|
|
|
<span class='type'>(<tt>Object</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>arguments which are passed to the task when it's executed.
|
|
(It might be prepended with other arguments, see the @yeild section).</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Yields:</p>
|
|
<ul class="yield">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="#reason-instance_method" title="Concurrent::Promises::Future#reason (method)">reason</a></span></tt>, <tt>*args</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>to the task.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Yield Returns:</p>
|
|
<ul class="yieldreturn">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'></span>
|
|
|
|
|
|
|
|
|
|
<div class='inline'><p>will become result of the returned Future.
|
|
Its returned value becomes <span class='object_link'><a href="#value-instance_method" title="Concurrent::Promises::Future#value (method)">#value</a></span> fulfilling it,
|
|
raised exception becomes <span class='object_link'><a href="#reason-instance_method" title="Concurrent::Promises::Future#reason (method)">#reason</a></span> rejecting it.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1002
|
|
1003
|
|
1004</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1002</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_rescue_on'>rescue_on</span><span class='lparen'>(</span><span class='id identifier rubyid_executor'>executor</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_task'>task</span><span class='rparen'>)</span>
|
|
<span class='const'>RescuePromise</span><span class='period'>.</span><span class='id identifier rubyid_new_blocked_by1'>new_blocked_by1</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='ivar'>@DefaultExecutor</span><span class='comma'>,</span> <span class='id identifier rubyid_executor'>executor</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_task'>task</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_future'>future</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="rescue_throttled_by-instance_method">
|
|
|
|
#<strong>rescue_throttled_by</strong>(throttle, *args, &block) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
<span class="not_defined_here">
|
|
Originally defined in module
|
|
<span class='object_link'><a href="Future/ThrottleIntegration.html#rescue_throttled_by-instance_method" title="Concurrent::Promises::Future::ThrottleIntegration#rescue_throttled_by (method)">ThrottleIntegration</a></span>
|
|
</span>
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Behaves as <span class='object_link'><a href="#rescue-instance_method" title="Concurrent::Promises::Future#rescue (method)">Concurrent::Promises::Future#rescue</a></span> but the it is throttled.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">See Also:</p>
|
|
<ul class="see">
|
|
|
|
<li><span class='object_link'><a href="#rescue-instance_method" title="Concurrent::Promises::Future#rescue (method)">Concurrent::Promises::Future#rescue</a></span></li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="result-instance_method">
|
|
|
|
#<strong>result</strong>(timeout = nil) ⇒ <tt><span class='object_link'><a href="../Array.html" title="Concurrent::Array (class)">Array</a></span>(Boolean, Object, Exception)</tt><sup>?</sup>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<div class="note notetag">
|
|
<strong>Note:</strong>
|
|
<div class='inline'><p>This function potentially blocks current thread until the Future is resolved.
|
|
Be careful it can deadlock. Try to chain instead.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<p>Returns triplet fulfilled?, value, reason.
|
|
Calls <span class='object_link'><a href="AbstractEventFuture.html#touch-instance_method" title="Concurrent::Promises::AbstractEventFuture#touch (method)">AbstractEventFuture#touch</a></span>.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>timeout</span>
|
|
|
|
|
|
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
|
|
|
|
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
|
|
|
|
—
|
|
<div class='inline'><p>the maximum time in second to wait.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="../Array.html" title="Concurrent::Array (class)">Array</a></span>(Boolean, Object, Exception)</tt>, <tt>nil</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>triplet of fulfilled?, value, reason, or nil
|
|
on timeout.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
933
|
|
934
|
|
935</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 933</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_result'>result</span><span class='lparen'>(</span><span class='id identifier rubyid_timeout'>timeout</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_internal_state'>internal_state</span><span class='period'>.</span><span class='id identifier rubyid_result'>result</span> <span class='kw'>if</span> <span class='id identifier rubyid_wait_until_resolved'>wait_until_resolved</span> <span class='id identifier rubyid_timeout'>timeout</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="run-instance_method">
|
|
|
|
#<strong>run</strong> ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Allows to use futures as green threads. The receiver has to evaluate to a future which
|
|
represents what should be done next. It basically flattens indefinitely until non Future
|
|
values is returned which becomes result of the returned future. Any encountered exception
|
|
will become reason of the returned future.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<div class="examples">
|
|
<p class="tag_title">Examples:</p>
|
|
|
|
|
|
<pre class="example code"><code><span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='id identifier rubyid_lambda'>lambda</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span>
|
|
<span class='id identifier rubyid_v'>v</span> <span class='op'>+=</span> <span class='int'>1</span>
|
|
<span class='id identifier rubyid_v'>v</span> <span class='op'><</span> <span class='int'>5</span> <span class='op'>?</span> <span class='const'><span class='object_link'><a href="../Promises.html" title="Concurrent::Promises (module)">Promises</a></span></span><span class='period'>.</span><span class='id identifier rubyid_future'><span class='object_link'><a href="FactoryMethods.html#future-instance_method" title="Concurrent::Promises::FactoryMethods#future (method)">future</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_v'>v</span>
|
|
<span class='kw'>end</span>
|
|
<span class='const'><span class='object_link'><a href="../Promises.html" title="Concurrent::Promises (module)">Promises</a></span></span><span class='period'>.</span><span class='id identifier rubyid_future'><span class='object_link'><a href="FactoryMethods.html#future-instance_method" title="Concurrent::Promises::FactoryMethods#future (method)">future</a></span></span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='period'>.</span><span class='id identifier rubyid_value!'><span class='object_link'><a href="#value!-instance_method" title="Concurrent::Promises::Future#value! (method)">value!</a></span></span> <span class='comment'># => 5</span></code></pre>
|
|
|
|
</div>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1142
|
|
1143
|
|
1144</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1142</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span>
|
|
<span class='const'>RunFuturePromise</span><span class='period'>.</span><span class='id identifier rubyid_new_blocked_by1'>new_blocked_by1</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='ivar'>@DefaultExecutor</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_future'>future</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="schedule-instance_method">
|
|
|
|
#<strong>schedule</strong>(intended_time) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Creates new event dependent on receiver scheduled to execute on/in intended_time.
|
|
In time is interpreted from the moment the receiver is resolved, therefore it inserts
|
|
delay into the chain.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>intended_time</span>
|
|
|
|
|
|
<span class='type'>(<tt>Numeric</tt>, <tt>Time</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p><code>Numeric</code> means to run in <code>intended_time</code> seconds.
|
|
<code>Time</code> means to run on <code>intended_time</code>.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1040
|
|
1041
|
|
1042
|
|
1043
|
|
1044
|
|
1045</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1040</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_schedule'>schedule</span><span class='lparen'>(</span><span class='id identifier rubyid_intended_time'>intended_time</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_chain'>chain</span> <span class='kw'>do</span>
|
|
<span class='id identifier rubyid_event'>event</span> <span class='op'>=</span> <span class='const'>ScheduledPromise</span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Synchronization/Object.html#new-class_method" title="Concurrent::Synchronization::Object.new (method)">new</a></span></span><span class='lparen'>(</span><span class='ivar'>@DefaultExecutor</span><span class='comma'>,</span> <span class='id identifier rubyid_intended_time'>intended_time</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_event'>event</span>
|
|
<span class='const'>ZipFutureEventPromise</span><span class='period'>.</span><span class='id identifier rubyid_new_blocked_by2'>new_blocked_by2</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_event'>event</span><span class='comma'>,</span> <span class='ivar'>@DefaultExecutor</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_future'>future</span>
|
|
<span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_flat'>flat</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="then-instance_method">
|
|
|
|
#<strong>then</strong>(*args, &task) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Shortcut of <span class='object_link'><a href="#then_on-instance_method" title="Concurrent::Promises::Future#then_on (method)">#then_on</a></span> with default <code>:io</code> executor supplied.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">See Also:</p>
|
|
<ul class="see">
|
|
|
|
<li><span class='object_link'><a href="#then_on-instance_method" title="Concurrent::Promises::Future#then_on (method)">#then_on</a></span></li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
972
|
|
973
|
|
974</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 972</span>
|
|
|
|
<span class='kw'>def</span> <span class='kw'>then</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_task'>task</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_then_on'>then_on</span> <span class='ivar'>@DefaultExecutor</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_task'>task</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="then_ask-instance_method">
|
|
|
|
#<strong>then_ask</strong>(actor) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
<span class="not_defined_here">
|
|
Originally defined in module
|
|
<span class='object_link'><a href="Future/ActorIntegration.html#then_ask-instance_method" title="Concurrent::Promises::Future::ActorIntegration#then_ask (method)">ActorIntegration</a></span>
|
|
</span>
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Asks the actor with its value.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>new future with the response form the actor</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="then_flat_event-instance_method">
|
|
|
|
#<strong>then_flat_event</strong>(*args, &block) ⇒ <tt><span class='object_link'><a href="Event.html" title="Concurrent::Promises::Event (class)">Event</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
<span class="not_defined_here">
|
|
Originally defined in module
|
|
<span class='object_link'><a href="Future/FlatShortcuts.html#then_flat_event-instance_method" title="Concurrent::Promises::Future::FlatShortcuts#then_flat_event (method)">FlatShortcuts</a></span>
|
|
</span>
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="Event.html" title="Concurrent::Promises::Event (class)">Event</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="then_flat_event_on-instance_method">
|
|
|
|
#<strong>then_flat_event_on</strong>(executor, *args, &block) ⇒ <tt><span class='object_link'><a href="Event.html" title="Concurrent::Promises::Event (class)">Event</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
<span class="not_defined_here">
|
|
Originally defined in module
|
|
<span class='object_link'><a href="Future/FlatShortcuts.html#then_flat_event_on-instance_method" title="Concurrent::Promises::Future::FlatShortcuts#then_flat_event_on (method)">FlatShortcuts</a></span>
|
|
</span>
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="Event.html" title="Concurrent::Promises::Event (class)">Event</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="then_flat_future-instance_method">
|
|
|
|
#<strong>then_flat_future</strong>(*args, &block) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
<span class="aliases">Also known as:
|
|
<span class="names"><span id='then_flat-instance_method'>then_flat</span></span>
|
|
</span>
|
|
|
|
|
|
|
|
<span class="not_defined_here">
|
|
Originally defined in module
|
|
<span class='object_link'><a href="Future/FlatShortcuts.html#then_flat_future-instance_method" title="Concurrent::Promises::Future::FlatShortcuts#then_flat_future (method)">FlatShortcuts</a></span>
|
|
</span>
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="then_flat_future_on-instance_method">
|
|
|
|
#<strong>then_flat_future_on</strong>(executor, *args, &block) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
<span class="aliases">Also known as:
|
|
<span class="names"><span id='then_flat_on-instance_method'>then_flat_on</span></span>
|
|
</span>
|
|
|
|
|
|
|
|
<span class="not_defined_here">
|
|
Originally defined in module
|
|
<span class='object_link'><a href="Future/FlatShortcuts.html#then_flat_future_on-instance_method" title="Concurrent::Promises::Future::FlatShortcuts#then_flat_future_on (method)">FlatShortcuts</a></span>
|
|
</span>
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="then_on-instance_method">
|
|
|
|
#<strong>then_on</strong>(executor, *args) {|value, *args| ... } ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Chains the task to be executed asynchronously on executor after it fulfills. Does not run
|
|
the task if it rejects. It will resolve though, triggering any dependent futures.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>executor</span>
|
|
|
|
|
|
<span class='type'>(<tt>Executor</tt>, <tt>:io</tt>, <tt>:fast</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>Instance of an executor or a name of the
|
|
global executor. The task is executed on it, default executor remains unchanged.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<span class='name'>args</span>
|
|
|
|
|
|
<span class='type'>(<tt>Object</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>arguments which are passed to the task when it's executed.
|
|
(It might be prepended with other arguments, see the @yeild section).</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Yields:</p>
|
|
<ul class="yield">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="#value-instance_method" title="Concurrent::Promises::Future#value (method)">value</a></span></tt>, <tt>*args</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>to the task.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Yield Returns:</p>
|
|
<ul class="yieldreturn">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'></span>
|
|
|
|
|
|
|
|
|
|
<div class='inline'><p>will become result of the returned Future.
|
|
Its returned value becomes <span class='object_link'><a href="#value-instance_method" title="Concurrent::Promises::Future#value (method)">#value</a></span> fulfilling it,
|
|
raised exception becomes <span class='object_link'><a href="#reason-instance_method" title="Concurrent::Promises::Future#reason (method)">#reason</a></span> rejecting it.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
984
|
|
985
|
|
986</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 984</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_then_on'>then_on</span><span class='lparen'>(</span><span class='id identifier rubyid_executor'>executor</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_task'>task</span><span class='rparen'>)</span>
|
|
<span class='const'>ThenPromise</span><span class='period'>.</span><span class='id identifier rubyid_new_blocked_by1'>new_blocked_by1</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='ivar'>@DefaultExecutor</span><span class='comma'>,</span> <span class='id identifier rubyid_executor'>executor</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_task'>task</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_future'>future</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="then_push_channel-instance_method">
|
|
|
|
#<strong>then_push_channel</strong>(channel) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
<span class="not_defined_here">
|
|
Originally defined in module
|
|
<span class='object_link'><a href="Future/NewChannelIntegration.html#then_push_channel-instance_method" title="Concurrent::Promises::Future::NewChannelIntegration#then_push_channel (method)">NewChannelIntegration</a></span>
|
|
</span>
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Returns a future which is fulfilled after the message is pushed to the channel.
|
|
May take a moment if the channel is full.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>channel</span>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="Channel.html" title="Concurrent::Promises::Channel (class)">Channel</a></span></tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>to push to.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>a future which is fulfilled after the message is pushed to the channel.
|
|
May take a moment if the channel is full.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="then_throttled_by-instance_method">
|
|
|
|
#<strong>then_throttled_by</strong>(throttle, *args, &block) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
<span class="not_defined_here">
|
|
Originally defined in module
|
|
<span class='object_link'><a href="Future/ThrottleIntegration.html#then_throttled_by-instance_method" title="Concurrent::Promises::Future::ThrottleIntegration#then_throttled_by (method)">ThrottleIntegration</a></span>
|
|
</span>
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Behaves as <span class='object_link'><a href="#then-instance_method" title="Concurrent::Promises::Future#then (method)">Concurrent::Promises::Future#then</a></span> but the it is throttled.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<div class="examples">
|
|
<p class="tag_title">Examples:</p>
|
|
|
|
|
|
<pre class="example code"><code><span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='int'>1</span><span class='op'>..</span><span class='int'>5</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
|
|
<span class='id identifier rubyid_db'>db</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_h'>h</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_h'>h</span><span class='period'>.</span><span class='id identifier rubyid_update'>update</span> <span class='id identifier rubyid_v'>v</span> <span class='op'>=></span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='rbrace'>}</span>
|
|
<span class='id identifier rubyid_max_two'>max_two</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Throttle.html" title="Concurrent::Throttle (class)">Throttle</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Synchronization/Object.html#new-class_method" title="Concurrent::Synchronization::Object.new (method)">new</a></span></span> <span class='int'>2</span>
|
|
|
|
<span class='id identifier rubyid_futures'>futures</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_data'>data</span><span class='op'>|</span>
|
|
<span class='const'><span class='object_link'><a href="../Promises.html" title="Concurrent::Promises (module)">Promises</a></span></span><span class='period'>.</span><span class='id identifier rubyid_future'><span class='object_link'><a href="FactoryMethods.html#future-instance_method" title="Concurrent::Promises::FactoryMethods#future (method)">future</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_data'>data</span><span class='op'>|</span>
|
|
<span class='comment'># un-throttled, concurrency level equal data.size
|
|
</span> <span class='id identifier rubyid_data'>data</span> <span class='op'>+</span> <span class='int'>1</span>
|
|
<span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_then_throttled_by'>then_throttled_by</span><span class='lparen'>(</span><span class='id identifier rubyid_max_two'>max_two</span><span class='comma'>,</span> <span class='id identifier rubyid_db'>db</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='comma'>,</span> <span class='id identifier rubyid_db'>db</span><span class='op'>|</span>
|
|
<span class='comment'># throttled, only 2 tasks executed at the same time
|
|
</span> <span class='comment'># e.g. limiting access to db
|
|
</span> <span class='id identifier rubyid_db'>db</span><span class='lbracket'>[</span><span class='id identifier rubyid_v'>v</span><span class='rbracket'>]</span>
|
|
<span class='kw'>end</span>
|
|
<span class='kw'>end</span>
|
|
|
|
<span class='id identifier rubyid_futures'>futures</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:value!</span><span class='rparen'>)</span> <span class='comment'># => [2, 3, 4, 5, nil]</span></code></pre>
|
|
|
|
</div>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">See Also:</p>
|
|
<ul class="see">
|
|
|
|
<li><span class='object_link'><a href="#then-instance_method" title="Concurrent::Promises::Future#then (method)">Concurrent::Promises::Future#then</a></span></li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="to_event-instance_method">
|
|
|
|
#<strong>to_event</strong> ⇒ <tt><span class='object_link'><a href="Event.html" title="Concurrent::Promises::Event (class)">Event</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Converts future to event which is resolved when future is resolved by fulfillment or rejection.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="Event.html" title="Concurrent::Promises::Event (class)">Event</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1154
|
|
1155
|
|
1156
|
|
1157
|
|
1158</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1154</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_event'>to_event</span>
|
|
<span class='id identifier rubyid_event'>event</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Promises.html" title="Concurrent::Promises (module)">Promises</a></span></span><span class='period'>.</span><span class='id identifier rubyid_resolvable_event'><span class='object_link'><a href="FactoryMethods.html#resolvable_event-instance_method" title="Concurrent::Promises::FactoryMethods#resolvable_event (method)">resolvable_event</a></span></span>
|
|
<span class='kw'>ensure</span>
|
|
<span class='id identifier rubyid_chain_resolvable'>chain_resolvable</span><span class='lparen'>(</span><span class='id identifier rubyid_event'>event</span><span class='rparen'>)</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="to_future-instance_method">
|
|
|
|
#<strong>to_future</strong> ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Returns self, since this is a future</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1162
|
|
1163
|
|
1164</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1162</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_future'>to_future</span>
|
|
<span class='kw'>self</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="value-instance_method">
|
|
|
|
#<strong>value</strong>(timeout = nil) ⇒ <tt>Object</tt><sup>?</sup>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<div class="note notetag">
|
|
<strong>Note:</strong>
|
|
<div class='inline'><p>This function potentially blocks current thread until the Future is resolved.
|
|
Be careful it can deadlock. Try to chain instead.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="note notetag">
|
|
<strong>Note:</strong>
|
|
<div class='inline'><p>Make sure returned <code>nil</code> is not confused with timeout, no value when rejected,
|
|
no reason when fulfilled, etc.
|
|
Use more exact methods if needed, like <span class='object_link'><a href="AbstractEventFuture.html#wait-instance_method" title="Concurrent::Promises::AbstractEventFuture#wait (method)">AbstractEventFuture#wait</a></span>, <span class='object_link'><a href="#value!-instance_method" title="Concurrent::Promises::Future#value! (method)">#value!</a></span>, <span class='object_link'><a href="#result-instance_method" title="Concurrent::Promises::Future#result (method)">#result</a></span>, etc.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<p>Return value of the future.
|
|
Calls <span class='object_link'><a href="AbstractEventFuture.html#touch-instance_method" title="Concurrent::Promises::AbstractEventFuture#touch (method)">AbstractEventFuture#touch</a></span>.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>timeout</span>
|
|
|
|
|
|
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
|
|
|
|
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
|
|
|
|
—
|
|
<div class='inline'><p>the maximum time in second to wait.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Object</tt>, <tt>nil</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>the value of the Future when fulfilled, nil on timeout or rejection.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
911
|
|
912
|
|
913</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 911</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span><span class='lparen'>(</span><span class='id identifier rubyid_timeout'>timeout</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_internal_state'>internal_state</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span> <span class='kw'>if</span> <span class='id identifier rubyid_wait_until_resolved'>wait_until_resolved</span> <span class='id identifier rubyid_timeout'>timeout</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="value!-instance_method">
|
|
|
|
#<strong>value!</strong>(timeout = nil) ⇒ <tt>Object</tt><sup>?</sup>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<div class="note notetag">
|
|
<strong>Note:</strong>
|
|
<div class='inline'><p>This function potentially blocks current thread until the Future is resolved.
|
|
Be careful it can deadlock. Try to chain instead.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="note notetag">
|
|
<strong>Note:</strong>
|
|
<div class='inline'><p>Make sure returned <code>nil</code> is not confused with timeout, no value when rejected,
|
|
no reason when fulfilled, etc.
|
|
Use more exact methods if needed, like <span class='object_link'><a href="AbstractEventFuture.html#wait-instance_method" title="Concurrent::Promises::AbstractEventFuture#wait (method)">AbstractEventFuture#wait</a></span>, <span class='object_link'><a href="#value!-instance_method" title="Concurrent::Promises::Future#value! (method)">#value!</a></span>, <span class='object_link'><a href="#result-instance_method" title="Concurrent::Promises::Future#result (method)">#result</a></span>, etc.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<p>Return value of the future.
|
|
Calls <span class='object_link'><a href="AbstractEventFuture.html#touch-instance_method" title="Concurrent::Promises::AbstractEventFuture#touch (method)">AbstractEventFuture#touch</a></span>.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>timeout</span>
|
|
|
|
|
|
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
|
|
|
|
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
|
|
|
|
—
|
|
<div class='inline'><p>the maximum time in second to wait.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Object</tt>, <tt>nil</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>the value of the Future when fulfilled, nil on timeout.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Raises:</p>
|
|
<ul class="raise">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Exception</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p><span class='object_link'><a href="#reason-instance_method" title="Concurrent::Promises::Future#reason (method)">#reason</a></span> on rejection</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
947
|
|
948
|
|
949</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 947</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_value!'>value!</span><span class='lparen'>(</span><span class='id identifier rubyid_timeout'>timeout</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_internal_state'>internal_state</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span> <span class='kw'>if</span> <span class='id identifier rubyid_wait_until_resolved!'>wait_until_resolved!</span> <span class='id identifier rubyid_timeout'>timeout</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="wait!-instance_method">
|
|
|
|
#<strong>wait!</strong>(timeout = nil) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>, <tt>true</tt>, <tt>false</tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<div class="note notetag">
|
|
<strong>Note:</strong>
|
|
<div class='inline'><p>This function potentially blocks current thread until the Future is resolved.
|
|
Be careful it can deadlock. Try to chain instead.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<p>Wait (block the Thread) until receiver is <span class='object_link'><a href="AbstractEventFuture.html#resolved%3F-instance_method" title="Concurrent::Promises::AbstractEventFuture#resolved? (method)">AbstractEventFuture#resolved?</a></span>.
|
|
Calls <span class='object_link'><a href="AbstractEventFuture.html#touch-instance_method" title="Concurrent::Promises::AbstractEventFuture#touch (method)">AbstractEventFuture#touch</a></span>.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>timeout</span>
|
|
|
|
|
|
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
|
|
|
|
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
|
|
|
|
—
|
|
<div class='inline'><p>the maximum time in second to wait.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>, <tt>true</tt>, <tt>false</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>self implies timeout was not used, true implies timeout was used
|
|
and it was resolved, false implies it was not resolved within timeout.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
<p class="tag_title">Raises:</p>
|
|
<ul class="raise">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Exception</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p><span class='object_link'><a href="#reason-instance_method" title="Concurrent::Promises::Future#reason (method)">#reason</a></span> on rejection</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
939
|
|
940
|
|
941
|
|
942</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 939</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_wait!'>wait!</span><span class='lparen'>(</span><span class='id identifier rubyid_timeout'>timeout</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_wait_until_resolved!'>wait_until_resolved!</span><span class='lparen'>(</span><span class='id identifier rubyid_timeout'>timeout</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_timeout'>timeout</span> <span class='op'>?</span> <span class='id identifier rubyid_result'>result</span> <span class='op'>:</span> <span class='kw'>self</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="with_default_executor-instance_method">
|
|
|
|
#<strong>with_default_executor</strong>(executor) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Crates new object with same class with the executor set as its new default executor.
|
|
Any futures depending on it will use the new default executor.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1049
|
|
1050
|
|
1051</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1049</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_with_default_executor'>with_default_executor</span><span class='lparen'>(</span><span class='id identifier rubyid_executor'>executor</span><span class='rparen'>)</span>
|
|
<span class='const'>FutureWrapperPromise</span><span class='period'>.</span><span class='id identifier rubyid_new_blocked_by1'>new_blocked_by1</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_executor'>executor</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_future'>future</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="zip-instance_method">
|
|
|
|
#<strong>zip</strong>(other) ⇒ <tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>
|
|
|
|
|
|
|
|
<span class="aliases">Also known as:
|
|
<span class="names"><span id='&-instance_method'>&</span></span>
|
|
</span>
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Creates a new event or a future which will be resolved when receiver and other are.
|
|
Returns an event if receiver and other are events, otherwise returns a future.
|
|
If just one of the parties is Future then the result
|
|
of the returned future is equal to the result of the supplied future. If both are futures
|
|
then the result is as described in <span class='object_link'><a href="FactoryMethods.html#zip_futures_on-instance_method" title="Concurrent::Promises::FactoryMethods#zip_futures_on (method)">Concurrent::Promises::FactoryMethods#zip_futures_on</a></span>.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
1008
|
|
1009
|
|
1010
|
|
1011
|
|
1012
|
|
1013
|
|
1014</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/concurrent/promises.rb', line 1008</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_zip'>zip</span><span class='lparen'>(</span><span class='id identifier rubyid_other'>other</span><span class='rparen'>)</span>
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_other'>other</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="" title="Concurrent::Promises::Future (class)">Future</a></span></span><span class='rparen'>)</span>
|
|
<span class='const'>ZipFuturesPromise</span><span class='period'>.</span><span class='id identifier rubyid_new_blocked_by2'>new_blocked_by2</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_other'>other</span><span class='comma'>,</span> <span class='ivar'>@DefaultExecutor</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_future'>future</span>
|
|
<span class='kw'>else</span>
|
|
<span class='const'>ZipFutureEventPromise</span><span class='period'>.</span><span class='id identifier rubyid_new_blocked_by2'>new_blocked_by2</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_other'>other</span><span class='comma'>,</span> <span class='ivar'>@DefaultExecutor</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_future'>future</span>
|
|
<span class='kw'>end</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="footer">
|
|
Generated by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_blank">yard</a>.
|
|
</div>
|
|
|
|
<script>
|
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
|
|
ga('create', 'UA-57940973-1', 'auto');
|
|
ga('send', 'pageview');
|
|
|
|
</script>
|
|
|
|
</div>
|
|
</body>
|
|
</html> |