/src/lib/sequencer/events/date_event.e

http://github.com/tybor/Liberty · Specman e · 74 lines · 37 code · 9 blank · 28 comment · 0 complexity · dcc57ef7e54a2c8c8305cc1cabac432c MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. class DATE_EVENT
  5. --
  6. -- Event: a timeout occurred
  7. --
  8. inherit
  9. TIME_EVENT
  10. create {TIME_EVENTS}
  11. make
  12. feature {EVENTS_SET}
  13. expect (events: EVENTS_SET)
  14. do
  15. events.at(expiration)
  16. set_expected(events)
  17. end
  18. occurred (events: EVENTS_SET): BOOLEAN
  19. do
  20. Result := events.current_time > expiration
  21. end
  22. feature {TIME_EVENTS}
  23. expiration: MICROSECOND_TIME
  24. in_time (timeout_ms: INTEGER)
  25. -- `timeout_ms' is the maximum time in milliseconds to wait from now.
  26. require
  27. not is_expected
  28. timeout_ms >= 0
  29. do
  30. expiration.update
  31. expiration.add_second(timeout_ms #// 1000)
  32. expiration.add_millisecond(timeout_ms #\\ 1000)
  33. end
  34. at_date (date: MICROSECOND_TIME)
  35. -- `date' is the last moment `wait' can wait.
  36. require
  37. not is_expected
  38. do
  39. expiration := date
  40. end
  41. feature {}
  42. make
  43. do
  44. end
  45. end -- class DATE_EVENT
  46. --
  47. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  48. --
  49. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  50. -- of this software and associated documentation files (the "Software"), to deal
  51. -- in the Software without restriction, including without limitation the rights
  52. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  53. -- copies of the Software, and to permit persons to whom the Software is
  54. -- furnished to do so, subject to the following conditions:
  55. --
  56. -- The above copyright notice and this permission notice shall be included in
  57. -- all copies or substantial portions of the Software.
  58. --
  59. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  60. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  61. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  62. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  63. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  64. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  65. -- THE SOFTWARE.