Changeset 11 for trunk


Ignore:
Timestamp:
11/11/07 17:01:23 (5 years ago)
Author:
dom
Message:

Refactoring: move file_monitor creation into forge module

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/forge.erl

    r2 r11  
    1212init() -> 
    1313    process_flag (trap_exit, true), 
    14     loop ([], new(), dashboard:new()). 
     14    loop ([], new(), dashboard:new(), []). 
    1515 
    16 loop (Listeners, Smiths, Dashboard) -> 
     16loop (Listeners, Smiths, Dashboard, Monitors) -> 
    1717    receive 
    1818        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)]); 
    2024        {add_event_handler, F} -> 
    21             loop ([F | Listeners], Smiths, Dashboard); 
    22         {_, found, File, _} -> 
     25            loop ([F | Listeners], Smiths, Dashboard, Monitors); 
     26        {found, File} -> 
    2327            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} -> 
    2630            Smith = fetch (File, Smiths), 
    2731            Smith ! {self(), modified}, 
    28             loop (Listeners, Smiths, Dashboard); 
     32            loop (Listeners, Smiths, Dashboard, Monitors); 
    2933        {_, _, _, Status, _} = Event -> 
    3034            New_dashboard = dashboard:update (Status, Dashboard), 
    3135            notify (Event, New_dashboard, Listeners), 
    32             loop (Listeners, Smiths, New_dashboard) 
     36            loop (Listeners, Smiths, New_dashboard, Monitors) 
    3337    end. 
    3438 
  • trunk/src/test_files_acceptance.erl

    r10 r11  
    1515              Server = forge:start (), 
    1616              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}, 
    1918              try 
    2019                  Test (Server, Dir, File_system), 
     
    2221                  ok 
    2322              after 
    24                   Server ! stop, 
    25                   file_monitor:stop (Monitor) 
     23                  Server ! stop 
    2624              end 
    2725      end). 
Note: See TracChangeset for help on using the changeset viewer.