/tutorial/sequencer/example2.e

http://github.com/tybor/Liberty · Specman e · 38 lines · 28 code · 7 blank · 3 comment · 1 complexity · 5e235d569f7cbf7ac7fe900ded70003e MD5 · raw file

  1. class EXAMPLE2
  2. -- Second example that shows how to do multiple cooperative jobs in
  3. -- parallel. The job is created with inline create and parameter
  4. -- given to the job.
  5. create {ANY}
  6. make
  7. feature {}
  8. lm: LOOP_STACK
  9. counter: INTEGER
  10. make
  11. do
  12. create lm.make
  13. lm.add_job(create {SIMPLE_BACKGROUND_JOB}.set_work(agent running("%R-"), Void, 1))
  14. lm.add_job(create {SIMPLE_BACKGROUND_JOB}.set_work(agent running("%R/"), Void, 1))
  15. lm.add_job(create {SIMPLE_BACKGROUND_JOB}.set_work(agent running("%R|"), Void, 1))
  16. lm.add_job(create {SIMPLE_BACKGROUND_JOB}.set_work(agent running("%R\"), Void, 1))
  17. lm.run
  18. end
  19. running (s: STRING): BOOLEAN
  20. do
  21. io.put_string(s)
  22. io.flush
  23. counter := counter + 1
  24. if counter \\ 100 = 0 then
  25. io.put_string("%Ncounter = ")
  26. io.put_integer(counter)
  27. io.put_new_line
  28. end
  29. Result := counter < 1000
  30. end
  31. end -- class EXAMPLE2