trait Offer[+T] extends AnyRef
An offer to communicate with another process. The offer is
parameterized on the type of the value communicated. An offer that
sends a value typically has type {{Unit}}. An offer is activated by
synchronizing it, which is done with sync()
.
Note that Offers are persistent values -- they may be synchronized multiple times. They represent a standing offer of communication, not a one-shot event.
The synchronization protocol
Synchronization is performed via a two-phase commit process.
prepare()
commences the transaction, and when the other party is
ready, it returns with a transaction object, Tx[T]
. This must then
be ackd or nackd. If both parties acknowledge, Tx.ack()
returns
with a commit object, containing the value. This finalizes the
transaction. Please see the Tx
documentation for more details on
that phase of the protocol.
Note that a user should never perform this protocol themselves --
synchronization should always be done with sync()
.
Future interrupts are propagated, and failure is passed through. It is up to the implementer of the Offer to decide on failure semantics, but they are always passed through in all of the combinators.
Note: There is a Java-friendly API for this trait: com.twitter.concurrent.AbstractOffer.
- Self Type
- Offer[T]
- Alphabetic
- By Inheritance
- Offer
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def ?: Future[T]
Alias for synchronize.
- def ??: T
Synchronize, blocking for the result.
- def andThen(f: => Unit): Unit
Synchronize (discarding the value), and then invoke the given closure.
Synchronize (discarding the value), and then invoke the given closure. Convenient for loops.
- def apply[U](f: (T) => U): Offer[U]
Synonym for
map()
.Synonym for
map()
. Useful in combination withOffer.choose()
andOffer.select()
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def const[U](f: => U): Offer[U]
Like {{map}}, but to a constant (call-by-name).
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def foreach(f: (T) => Unit): Unit
Synchronize on this offer indefinitely, invoking the given {{f}} with each successfully synchronized value.
Synchronize on this offer indefinitely, invoking the given {{f}} with each successfully synchronized value. A receiver can use this to enumerate over all received values.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[U](f: (T) => U): Offer[U]
Map this offer of type {{T}} into one of type {{U}}.
Map this offer of type {{T}} into one of type {{U}}. The translation (performed by {{f}}) is done after the {{Offer[T]}} has successfully synchronized.
- def mapConst[U](c: U): Offer[U]
Java-friendly analog of
const()
. - def mapConstFunction[U](f: => U): Offer[U]
Java-friendly analog of
const()
. - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def or[U](other: Offer[U]): Offer[Either[T, U]]
- def orElse[U >: T](other: Offer[U]): Offer[U]
An offer that, when synchronized, attempts to synchronize {{this}} immediately, and if it fails, synchronizes on {{other}} instead.
An offer that, when synchronized, attempts to synchronize {{this}} immediately, and if it fails, synchronizes on {{other}} instead. This is useful for providing default values. Eg.:
offer orElse Offer.const { computeDefaultValue() }
- def sync(): Future[T]
Synchronizes this offer, returning a future representing the result of the synchronization.
- def syncWait(): T
Synchronize this offer, blocking for the result.
Synchronize this offer, blocking for the result. See {{sync()}} and {{com.twitter.util.Future.apply()}}
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()