PageRenderTime 50ms CodeModel.GetById 43ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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