eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'AbstractBackgroundJob':

Home

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

Class: AbstractBackgroundJob


Inheritance:

   Object
   |
   +--AbstractBackgroundJob
      |
      +--BackgroundJob
      |
      +--BackgroundPeriodicalJob
      |
      +--BackgroundQueueProcessingJob

Package:
stx:libbasic2
Category:
System-Support
Version:
rev: 1.5 date: 2017/02/10 10:22:15
user: cg
file: AbstractBackgroundJob.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Jan Vrany <jan.vrany@fit.cvut.cz>

Description:


Ab AbstractBackgroundJob is a base superclass for any kind of background
processing job. Possible uses include (but not limited to): 
copying files, syntax higlighting, live searching, autosave, etc.

See subclasses for various form of background processing.

A task to be processed in a background is given to instances
in a form of a block or a message send. The background task must 
be then started by sending a #start message to the instance of 
the job. A job may be restarted any time by sending #restart or
terminated by sending #stop. Sending #start to already started
job does nothing.

Implementation note: 
The the task is actually processed in a separate, exclusive    
worker thread, so an explicit synchronization have to
be done iff the task accesses possibly shared data. 
The worker exists only iff the job is actually running. When 
the task is finished, worker thread terminates.


[instance variables:]
    name    <String|nil>            A user friendly name of a job,
                                    useful for identifing job's thread in
                                    process list.
    job     <Block|MessageSend>     A task to perform in background.
    priority<Integer>               A priority of worker thread. Defaults to
                                    Processor userBackgroundPriority.
    thread  <Process|nil>           The worker thread
    running <Boolean>               Boolean value indicating whether
                                    tasks already started or not.





Related information:

    BackgroundJob
    BackgroundQueueProcessingJob
    BackgroundPeriodicalJob
    Tools::CodeHighlightingService
    (uses
    this
    class)

Class protocol:

instance creation
o  named: name

o  named: name on: block

o  new
return an initialized instance

o  on: block

queries
o  isAbstract
Return if this class is an abstract class.
True is returned here for myself only; false for subclasses.
Abstract subclasses must redefine this again.


Instance protocol:

accessing
o  initiatingThread

o  initiatingThread: something

o  isDebuggerJob

o  isDebuggerJob: aBoolean
added to allow suppression of breakpoints/halts of a
job started by the debugger
(if you ask what this is for,
try to put a breakpoint into the syntaxhighlighter in the old schema)

o  job

o  job: aBlockOrMessageSend
Sets the job to be done. The job is sent
#value from the worker thread once started

o  name

o  name: aString

o  priority

o  priority: anInteger
Set the priority of a worker thread

o  thread
Return the thread (an instance of Process) that currently
processes the job or nil. if no processing is currently performed.

initialization
o  initialize
super initialize. -- commented since inherited method does nothing

private
o  setupThread: t priority: p
Sets up worker thread

processing
o  process
Actually perform the job. This method is called from the background worker thread

** This method raises an error - it must be redefined in concrete classes **

queries
o  running
Return true if the job is actually running, i.e., if it
is actually computing a value, contrary to #scheduled, that
returns true even if computation actually did not start
(i.e., thread is created but was not scheduled so far)

o  scheduled
Return true, if the job has been already started

start & stop
o  abort
Abort the job, if it is running. Similar to #stop, but raises
abort operation request so the job has a chance to terminate
gracefully

o  restart

o  start

o  startWithPriority: prio

o  stop
raise its prio to make it terminate quickly



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 28 Mar 2024 14:30:28 GMT