PageRenderTime 17ms CodeModel.GetById 9ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/src/lib/sequencer/job.e

http://github.com/tybor/Liberty
Specman e | 102 lines | 42 code | 10 blank | 50 comment | 0 complexity | 9ba1ab52d5082f7025ee12702f73738f MD5 | raw file
  1-- This file is part of a Liberty Eiffel library.
  2-- See the full copyright at the end.
  3--
  4deferred class JOB
  5   --The job's life will looks like :
  6   --   do
  7   --      prepare
  8   --      if is_ready then
  9   --         continue
 10   --   repeat while not done
 11   --
 12   -- If the same job has to live again, restart is called.
 13   --
 14   -- Note: never change a job's priority after inserting it in loop_item.
 15   --       Priority should only be set at creation time.
 16   --
 17
 18insert
 19   PLATFORM
 20
 21feature {JOB, LOOP_ITEM}
 22   priority: INTEGER
 23         -- never change a job's priority after inserting it in loop_item.
 24         -- Priority should only be set at creation time.
 25
 26feature {LOOP_ITEM}
 27   prepare (events: EVENTS_SET)
 28         -- Use `events' to describe condition that make this job ready to `continue'.
 29         -- `events' describe the conditions to be satisfied before
 30         -- running this job for one more step.
 31      require
 32         events /= Void
 33         not events.queryable
 34         not done
 35      deferred
 36      end
 37
 38   is_ready (events: EVENTS_SET): BOOLEAN
 39         -- Check if this job is ready to continue his work.
 40         -- `events' describe the events which occurred.
 41      require
 42         events /= Void
 43         events.queryable
 44         not done
 45      deferred
 46      end
 47
 48   continue
 49         -- Continue to do the job.
 50         -- The work to do has to be small work and non blocking, it
 51         -- will continue on next call.
 52      require
 53         not done
 54      deferred
 55      end
 56
 57   done: BOOLEAN
 58         -- `done' returns `True' when the job is finished. Then the
 59         -- job may be `restart'(ed) if it needs to run again.
 60      deferred
 61      end
 62
 63   restart
 64         -- Configure the job like in its initial state.
 65         -- Example: when some window dialog appears a second time, all
 66         -- jobs from this window are restarted.
 67      require
 68         done
 69      deferred
 70      ensure
 71         not done
 72      end
 73
 74   infix "<" (other: JOB): BOOLEAN
 75      do
 76         Result := priority < other.priority
 77      end
 78
 79invariant
 80   priority /= Minimum_integer
 81
 82end -- class JOB
 83--
 84-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
 85--
 86-- Permission is hereby granted, free of charge, to any person obtaining a copy
 87-- of this software and associated documentation files (the "Software"), to deal
 88-- in the Software without restriction, including without limitation the rights
 89-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 90-- copies of the Software, and to permit persons to whom the Software is
 91-- furnished to do so, subject to the following conditions:
 92--
 93-- The above copyright notice and this permission notice shall be included in
 94-- all copies or substantial portions of the Software.
 95--
 96-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 97-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 98-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 99-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
100-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
101-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
102-- THE SOFTWARE.