PageRenderTime 16ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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