org.dbpedia.extraction.util

Workers

class Workers[T <: AnyRef] extends Closeable

A simple fixed size thread-pool.

TODO: If a worker thread dies because of an uncaught exception, it just goes away and we may not fully use all CPUs. Maybe we should start a new worker thread? Or use a thread pool who does that for us? On the other hand - what about worker.init() and worker.destroy()? We probably don't want to call them twice. No, I guess it's better to let the thread die. Users can always catch Throwable in their implementation of Worker.process().

FIXME: If all worker threads die because of uncaught exceptions, the master thread will probably still add tasks to the queue and block forever. When a worker thread dies, it should count down the number of live threads and if none are left interrupt the master thread if it is blocking in process(). But what if there are multiple master threads? Ough. We need more ways to communicate between masters and workers...

Linear Supertypes
Closeable, AutoCloseable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Workers
  2. Closeable
  3. AutoCloseable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Workers(availThreads: Int, queueLength: Int, factory: ⇒ Worker[T])

    availThreads

    number of threads in pool

    queueLength

    max length of work queue

    factory

    called during initialization of this class to create a worker for each thread

Value Members

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

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

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

    Definition Classes
    AnyRef → Any
  4. object WorkerObjectState extends Enumeration

    Provides the state of a package of work

  5. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  6. def checkWorkerProcess(hash: Int): Option[WorkerObjectState.Value]

    check the state of a queued Worker object

    check the state of a queued Worker object

    hash

    - hashcode of queued object

    returns

    WorkerState

  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def close(): Unit

    Definition Classes
    Workers → Closeable → AutoCloseable
  9. final def eq(arg0: AnyRef): Boolean

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

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

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

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

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

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

    Definition Classes
    AnyRef
  16. final def notify(): Unit

    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  18. final def process(value: T, dependentOn: Int = 1): Unit

    Add a value to the queue.

    Add a value to the queue. A thread will take the value and let its worker process it. If queue is full and all threads are busy, wait until a thread becomes available.

  19. final def process(value: T, dependentOn: T): Unit

  20. final def start(): Unit

    Start all threads.

    Start all threads. Each thread will initialize its worker.

  21. final def stop(): Unit

    Stop all threads and wait for them to finish.

    Stop all threads and wait for them to finish. Each thread will destroy its worker.

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

    Definition Classes
    AnyRef
  23. def toString(): String

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

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Closeable

Inherited from AutoCloseable

Inherited from AnyRef

Inherited from Any

Ungrouped