org.positronicnet.notifications

Notifier

trait Notifier [T] extends AnyRef

Basic trait for actor-like objects which manage state of type T. Actors ordinarily operate on a thread associated with the state they manage (e.g., the worker thread associated with a Database). Code running on other threads usually communicates with them by sending actions using an actor-like notifier ! action style.

The base Notifier trait specifies a set of actions for querying the state, and requesting updates when it changes. Subclasses (e.g., RecordManager) typically support other actions which request changes to happen (which may, in turn, cause watchers to be notified).

The primary reason for doing things in an actor-style syntax in Android is to deal with the fairly stringent best-practice requirements for Android "user interface threads" --- specifically, the requirement that they shouldn't be waiting for anything else, even local disk I/O (let alone, say, a network operation). So, all that stuff needs to happen on background threads; we use actor style to help keep the concurrency manageable.

However, there are also circumstances where concurrency is a nuisance. For instance, an Android Service or BroadcastReceiver may want to be sure that an operation has completed before signalling that it has finished itself.

For these situations, you can also request that an action be performed onThisThread, as in

notifier.onThisThread( Fetch{ value => ... } )

which performs the Fetch and runs the body on the current thread, forgoing all concurrency. (Though for this particular case, there's a special-case fetchOnThisThread method which simply fetches the monitored state and returns it as the value.)

See org.positronicnet.notifications.Actions for definitions of the common action types.

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Notifier
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Abstract Value Members

  1. def ! (action: Action[T]): Unit

    Perform the action, usually on a worker thread associated with this notifier.

    Perform the action, usually on a worker thread associated with this notifier. Results may be posted back to the calling thread, viz. the conventions documented in org.positronicnet.notifications.Actions.

    Attributes
    abstract
  2. def fetchOnThisThread : T

    Synchronously fetch the value being monitored by this Notifier.

    Synchronously fetch the value being monitored by this Notifier.

    Attributes
    abstract
  3. def onThisThread (action: Action[T]): Unit

    Perform the action, synchronously on the calling thread.

    Perform the action, synchronously on the calling thread.

    Attributes
    abstract

Concrete Value Members

  1. def != (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  2. def != (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  3. def ## (): Int

    Attributes
    final
    Definition Classes
    AnyRef → Any
  4. def == (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  5. def == (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  6. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  7. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  8. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  9. def equals (arg0: Any): Boolean

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

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef
  12. def hashCode (): Int

    Definition Classes
    AnyRef → Any
  13. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  14. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  15. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  16. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  17. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  18. def toString (): String

    Definition Classes
    AnyRef → Any
  19. def wait (): Unit

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

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

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any