- Timestamp:
- 11/11/07 17:01:23 (5 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
-
forge.erl (modified) (1 diff)
-
test_files_acceptance.erl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/forge.erl
r2 r11 12 12 init() -> 13 13 process_flag (trap_exit, true), 14 loop ([], new(), dashboard:new() ).14 loop ([], new(), dashboard:new(), []). 15 15 16 loop (Listeners, Smiths, Dashboard ) ->16 loop (Listeners, Smiths, Dashboard, Monitors) -> 17 17 receive 18 18 stop -> 19 bye; 19 [file_monitor:stop (M) || M <- Monitors]; 20 {monitor_files, File_system, Dir} -> 21 Forge = self(), 22 Tell_server = fun (Event, File_name, _) -> Forge ! {Event, File_name} end, 23 loop (Listeners, Smiths, Dashboard, [file_monitor:start (File_system, Dir, Tell_server)]); 20 24 {add_event_handler, F} -> 21 loop ([F | Listeners], Smiths, Dashboard );22 { _, found, File, _} ->25 loop ([F | Listeners], Smiths, Dashboard, Monitors); 26 {found, File} -> 23 27 Smith = file_handler (filename:extension (File), File), 24 loop (Listeners, add_smith (File, Smith, Smiths), Dashboard );25 { _, modified, File, _} ->28 loop (Listeners, add_smith (File, Smith, Smiths), Dashboard, Monitors); 29 {modified, File} -> 26 30 Smith = fetch (File, Smiths), 27 31 Smith ! {self(), modified}, 28 loop (Listeners, Smiths, Dashboard );32 loop (Listeners, Smiths, Dashboard, Monitors); 29 33 {_, _, _, Status, _} = Event -> 30 34 New_dashboard = dashboard:update (Status, Dashboard), 31 35 notify (Event, New_dashboard, Listeners), 32 loop (Listeners, Smiths, New_dashboard )36 loop (Listeners, Smiths, New_dashboard, Monitors) 33 37 end. 34 38 -
trunk/src/test_files_acceptance.erl
r10 r11 15 15 Server = forge:start (), 16 16 Server ! {add_event_handler, fun (Event) -> Listener ! {self (), Event} end}, 17 Tell_server = fun (Event, File_name, FS) -> Server ! {self (), Event, File_name, FS} end, 18 Monitor = file_monitor:start (File_system, Dir, Tell_server), 17 Server ! {monitor_files, File_system, Dir}, 19 18 try 20 19 Test (Server, Dir, File_system), … … 22 21 ok 23 22 after 24 Server ! stop, 25 file_monitor:stop (Monitor) 23 Server ! stop 26 24 end 27 25 end).
Note: See TracChangeset
for help on using the changeset viewer.
