Trait/Object

com.twitter.concurrent

Offer

Related Docs: object Offer | package concurrent

Permalink

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]
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Offer
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def prepare(): Future[Tx[T]]

    Permalink

    Prepare a new transaction.

    Prepare a new transaction. This is the first stage of the 2 phase commit. This is typically only called by the offer implementation directly or by combinators.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def ?: Future[T]

    Permalink

    Alias for synchronize.

  5. def ??: T

    Permalink

    Synchronize, blocking for the result.

  6. def andThen(f: ⇒ Unit): Unit

    Permalink

    Synchronize (discarding the value), and then invoke the given closure.

    Synchronize (discarding the value), and then invoke the given closure. Convenient for loops.

  7. def apply[U](f: (T) ⇒ U): Offer[U]

    Permalink

    Synonym for map().

    Synonym for map(). Useful in combination with Offer.choose() and Offer.select()

  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. def const[U](f: ⇒ U): Offer[U]

    Permalink

    Like {{map}}, but to a constant (call-by-name).

  11. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  13. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. def foreach(f: (T) ⇒ Unit): Unit

    Permalink

    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.

  15. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  16. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  18. def map[U](f: (T) ⇒ U): Offer[U]

    Permalink

    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.

  19. def mapConst[U](c: U): Offer[U]

    Permalink

    Java-friendly analog of const().

  20. def mapConstFunction[U](f: ⇒ U): Offer[U]

    Permalink

    Java-friendly analog of const().

  21. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  22. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  23. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. def or[U](other: Offer[U]): Offer[Either[T, U]]

    Permalink
  25. def orElse[U >: T](other: Offer[U]): Offer[U]

    Permalink

    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() }
  26. def sync(): Future[T]

    Permalink

    Synchronizes this offer, returning a future representing the result of the synchronization.

  27. def syncWait(): T

    Permalink

    Synchronize this offer, blocking for the result.

    Synchronize this offer, blocking for the result. See {{sync()}} and {{com.twitter.util.Future.apply()}}

  28. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  29. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  30. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def apply(): Future[T]

    Permalink

    Synonym for sync()

    Synonym for sync()

    Annotations
    @deprecated
    Deprecated

    (Since version 5.x) use sync() instead

Inherited from AnyRef

Inherited from Any

Ungrouped