Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typo ("percent-deteriorated" -> "cuddle-hunger-level") #97

Merged
merged 1 commit into from
Feb 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/cftbat/zombie-metaphysics.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h2>Atoms</h2>
<p class="Body">In the Ruby example in Listing 10-1, we saw how object data could change while you try to log it on a separate thread. There’s no danger of that happening when using atoms to manage state, because each state is immutable. Here’s how you could log a zombie’s state with <code>println</code>:</p>
<div class="listingblock"><div class="content"><pre class="pygments highlight"><code data-lang="clojure" class="block"><span class="tok-p">(</span><span class="tok-k">let </span><span class="tok-p">[</span><span class="tok-nv">zombie-state</span> <span class="tok-o">@</span><span class="tok-nv">fred</span><span class="tok-p">]</span>
<span class="tok-p">(</span><span class="tok-k">if </span><span class="tok-p">(</span><span class="tok-nb">&gt;= </span><span class="tok-p">(</span><span class="tok-ss">:percent-deteriorated</span> <span class="tok-nv">zombie-state</span><span class="tok-p">)</span> <span class="tok-mi">50</span><span class="tok-p">)</span>
<span class="tok-p">(</span><span class="tok-nf">future</span> <span class="tok-p">(</span><span class="tok-nb">println </span><span class="tok-p">(</span><span class="tok-ss">:percent-deteriorated</span> <span class="tok-nv">zombie-state</span><span class="tok-p">)))))</span>
<span class="tok-p">(</span><span class="tok-nf">future</span> <span class="tok-p">(</span><span class="tok-nb">println </span><span class="tok-p">(</span><span class="tok-ss">:cuddle-hunger-level</span> <span class="tok-nv">zombie-state</span><span class="tok-p">)))))</span>
</code></pre></div></div>

<p class="Body">The problem with the Ruby example in Listing 10-1 was that it took two steps to read the zombie’s two attributes, and some other thread could have changed those attributes in between the two steps. However, by using atoms to refer to immutable data structures, you only have to perform one read, and the data structure returned won’t get altered by another thread.</p>
Expand Down