/[eiffelstudio]/trunk/eweasel/tests/dotnet005/c.e
ViewVC logotype

Annotation of /trunk/eweasel/tests/dotnet005/c.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 65297 - (hide annotations)
Thu Nov 30 20:22:33 2006 UTC (13 years, 1 month ago) by manus
File size: 1804 byte(s)
Moved from trunk/Src/eweasel to trunk/eweasel so that a simple checkout of the source code is not penalized by the lenghty process of checking out all the tests of eweasel.
1 manus 65296 class C
2    
3     inherit
4     THREAD
5     $THREAD_CONTROL
6    
7     create
8     make
9    
10     feature {NONE} -- Creation
11    
12     make (test_number: INTEGER; delay: BOOLEAN; test_sem: SEMAPHORE) is
13     -- Launch test number `test_number' that creates
14     -- a thread that will be execute test when `test_sem'
15     -- is open.
16     require
17     test_sem_not_void: test_sem /= Void
18     do
19     internal_number := test_number
20     is_delayed := delay
21     create thread_sem.make (0)
22     common_sem := test_sem
23     launch
24     thread_sem.wait
25     end
26    
27     feature -- Basic operations
28    
29     execute is
30     do
31     -- Notify that this thread has been started
32     thread_sem.post
33     -- Wait until all other threads start
34     common_sem.wait
35     if not is_delayed then
36     -- Let delayed threads to start execution.
37     -- Delay execution for 0.5 second.
38     sleep (500_000_000)
39     end
40     -- Test result of once function
41     report_test_result (internal_number, number = internal_number)
42     end
43    
44     feature {NONE} -- Output
45    
46     report_test_result (test_number: INTEGER; succeeded: BOOLEAN) is
47     -- Report whether a test number `test_number'
48     -- is `succeeded' or not.
49     require
50     positive_test_number: test_number > 0
51     do
52     io.put_string ("Test " + test_number.out + ": ")
53     if succeeded then
54     io.put_string ("OK")
55     else
56     io.put_string ("FAILED")
57     end
58     io.put_new_line
59     end
60    
61     feature {NONE} -- Status
62    
63     number: INTEGER is
64     -- Test number
65     once
66     Result := internal_number
67     if is_delayed then
68     -- Delay execution for 1 second.
69     sleep (1_000_000_000)
70     end
71     end
72    
73     internal_number: INTEGER
74     -- Current test number
75    
76     is_delayed: BOOLEAN
77     -- Should execution be delayed to let other thread(s) to run?
78    
79     feature {NONE} -- Data
80    
81     thread_sem: SEMAPHORE
82     -- Semaphore for thread created by current object
83    
84     common_sem: SEMAPHORE
85     -- Semaphore for all threads
86    
87     end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23