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

use explicit map calls #11

Merged
merged 1 commit into from Aug 26, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions effectivescala.mo
Expand Up @@ -1596,10 +1596,10 @@ Using Offer/Brokers, we can express this quite naturally:
private[this] def loop(connq: Queue[Conn]) {
Offer.choose(
if (connq.isEmpty) Offer.never else {
val (head, rest) = connq.dequeue
waiters.send(head) { _ => loop(rest) }
val (head, rest) = connq.dequeue()
waiters.send(head) map { _ => loop(rest) }
},
returnConn.recv { c => loop(connq enqueue c) }
returnConn.recv map { c => loop(connq.enqueue(c)) }
).sync()
}

Expand All @@ -1612,8 +1612,8 @@ reasoning further. The interface to the pool is also through an Offer, so if a c
wishes to apply a timeout, they can do so through the use of combinators:

val conn: Future[Option[Conn]] = Offer.choose(
pool.get { conn => Some(conn) },
Offer.timeout(1.second) { _ => None }
pool.get map { conn => Some(conn) },
Offer.timeout(1.second) map { _ => None }
).sync()

No extra bookkeeping was required to implement timeouts; this is due to
Expand Down