/tutorial/sequencer/example1.e

http://github.com/tybor/Liberty · Specman e · 45 lines · 35 code · 9 blank · 1 comment · 1 complexity · 5a80f7dce89f3e08a1028b6f935d4bbb MD5 · raw file

  1. class EXAMPLE1
  2. -- Simple example that shows how to do multiple cooperative jobs in parallel.
  3. create {ANY}
  4. make
  5. feature {}
  6. lm: LOOP_STACK
  7. counter: INTEGER
  8. continue: BOOLEAN
  9. make
  10. local
  11. job1, job2: SIMPLE_BACKGROUND_JOB
  12. do
  13. create lm.make
  14. create job1.set_work(agent work1, Void, 1)
  15. create job2.set_work(agent work2, Void, 1)
  16. lm.add_job(job1)
  17. lm.add_job(job2)
  18. continue := True
  19. lm.run
  20. end
  21. work1: BOOLEAN
  22. do
  23. io.put_integer(counter)
  24. io.put_new_line
  25. counter := counter + 1
  26. if counter > 5 then
  27. continue := False
  28. end
  29. Result := continue
  30. end
  31. work2: BOOLEAN
  32. do
  33. io.put_string("Hello !%N")
  34. Result := continue
  35. end
  36. end -- class EXAMPLE1