/src/lib/sequencer/simple_background_job.e

http://github.com/tybor/Liberty · Specman e · 72 lines · 37 code · 9 blank · 26 comment · 1 complexity · 0ef6dd320a32ec70ee77a0a78be2d68b MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. class SIMPLE_BACKGROUND_JOB
  5. -- Describe a job to be executed in the background, when there is nothing
  6. -- more important to do. Such a job is ready to run at any time.
  7. inherit
  8. BACKGROUND_JOB
  9. create {ANY}
  10. set_work
  11. feature {ANY}
  12. set_work (t: like task; tr: like task_restart; prio: INTEGER)
  13. -- t has to return True while continue
  14. require
  15. t /= Void
  16. prio /= Minimum_integer
  17. do
  18. task := t
  19. task_restart := tr
  20. priority := prio
  21. ensure
  22. priority = prio
  23. end
  24. feature {LOOP_ITEM}
  25. done: BOOLEAN
  26. continue
  27. local
  28. cont: BOOLEAN
  29. do
  30. cont := task.item([])
  31. done := not cont
  32. end
  33. restart
  34. do
  35. if task_restart /= Void then
  36. task_restart.call([])
  37. end
  38. done := False
  39. end
  40. feature {}
  41. task: PREDICATE[TUPLE]
  42. task_restart: PROCEDURE[TUPLE]
  43. end -- class SIMPLE_BACKGROUND_JOB
  44. --
  45. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  46. --
  47. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  48. -- of this software and associated documentation files (the "Software"), to deal
  49. -- in the Software without restriction, including without limitation the rights
  50. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  51. -- copies of the Software, and to permit persons to whom the Software is
  52. -- furnished to do so, subject to the following conditions:
  53. --
  54. -- The above copyright notice and this permission notice shall be included in
  55. -- all copies or substantial portions of the Software.
  56. --
  57. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  59. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  60. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  61. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  62. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  63. -- THE SOFTWARE.