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