/tutorial/signal/example0.e
Specman e | 38 lines | 25 code | 6 blank | 7 comment | 3 complexity | d9866e3d8578b5f553ed1fdf5c180d98 MD5 | raw file
1class EXAMPLE0 2 -- Signal example0 3 -- This example shows the use of SIGNAL_0. This signal only means that an 4 -- event occurred. 5 6create {ANY} 7 make 8 9feature {} 10 event: SIGNAL_0 11 12 make 13 do 14 create event.make 15 register 16 io.put_string("Event occur for first time:%N") 17 event.emit 18 io.put_string("Event occur for second time:%N") 19 event.emit 20 end 21 22 register 23 -- In real examples, other objects will connect to the event so 24 -- arbitrary functions of their choice may be executed when the 25 -- event occur. 26 do 27 event.connect(agent io.put_string("Event occur...%N")) 28 -- functions with arguments may be used too! Simply give their values. 29 event.connect(agent foo) 30 end 31 32 foo 33 do 34 io.put_string(once "This function does what needs to be% 35 % done for this event%N") 36 end 37 38end -- class EXAMPLE0