eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'OperationQueue':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: OperationQueue


Inheritance:

   Object
   |
   +--OperationQueue

Package:
stx:libbasic2
Category:
Kernel-Processes
Version:
rev: 1.17 date: 2023/01/09 18:09:33
user: cg
file: OperationQueue.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


An operationQueue allows operations (i.e. actions) to be evaluated in
a first-come-first-serve queue like fashion. A single consumer process
waits for orders to be enqueued and evaluates them (as they come).
Producer processes which want to have some operation performed may
enqueue these. Producers are suspended, until the operation is finished.
If multiple orders which compare equal are enqueued by multiple producers,
the operation is only evaluated once, and both producers will wake up when
the operation has finished.

copyright

COPYRIGHT (c) 2000 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

instance creation
o  new
(comment from inherited method)
return an instance of myself without indexed variables

o  new: n
(comment from inherited method)
return an instance of myself with anInteger indexed variables


Instance protocol:

accessing
o  consumerProcess
return the value of the instance variable 'consumerProcess' (automatically generated)

o  consumerProcessPriority
return the value of the instance variable 'consumerProcessPriority' (automatically generated)

o  consumerProcessPriority: something
set the value of the instance variable 'consumerProcessPriority' (automatically generated)

o  synchronizationSemaphore
return a synchronization semaphore for myself;
this will be used by synchronized:[...]

consumer
o  fetchNextOperationAndExecute
dequeue the next order, evaluate it and wake up waiters

o  startConsumerProcess
must check again to avoid race condition

o  stopConsumerProcess

debugging support
o  copyContextChain: aContext
for debugging - return a copy if a context chain

o  linkContextChain: aConsumerChain
for debugging - concatenate aConsumerChain to my own context chain (to make debugging easier)

initialization
o  initializeCount: n

producer
o  scheduleOperation: anotherOperation
enqueue an order (something that understands #value) to the op-queue;
wait until the operation has performed (#value been sent),
return the result of the #value send.
If a similar order is already in the queue, wait for that one to finish.

o  scheduleOperation: anotherOperation asynchronous: asynchronous
enqueue an order (something that understands #value) to the op-queue;
if asynchronous is false, wait until the operation has performed (#value been sent),
return the result of the #value send.
If a similar order is already in the queue, wait for that one to finish.
If asynchronous is true, do not wait (but also: do not return a return value)

queries
o  size
return the number of operations in the queue


Private classes:

    OperationInQueue

Examples:


two orders; done sequentially:
    |opQ|

    opQ := OperationQueue new.
    opQ scheduleOperation:[ Transcript showCR:'hello world-1'].
    opQ scheduleOperation:[ Transcript showCR:'hello world-2'].

only 10 outputs (same operation entered by multiple producers):
    |p1 p2 p3 opQ order|

    opQ := OperationQueue new.
    order := [ Transcript showCR:'hello world '].
    p1 := [
            1 to:10 do:[:i |
                opQ scheduleOperation:order.
            ]
          ] fork.
    p2 := [
            1 to:10 do:[:i |
                opQ scheduleOperation:order.
            ]
          ] fork.
    p3 := [
            1 to:10 do:[:i |
                opQ scheduleOperation:order.
            ]
          ] fork.


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:44:26 GMT