ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/GoogleTron/GoogleTron.cpp
(Generate patch)

Comparing GoogleTron/GoogleTron.cpp (file contents):
Revision 676 by douglas, 2006-03-04T05:15:00-08:00 vs.
Revision 677 by douglas, 2006-03-04T07:11:04-08:00

# Line 12 | Line 12
12  
13   #include "GoogleTron.hpp"
14   #include "GzipWriter.hpp"
15 + #include "Sleep.hpp"
16  
17   int Main(const app::Options &options)
18   {
19 <        GoogleTron tron;
19 >        GoogleTron tron(_B("sitemap.gz"));
20  
21          return 0;
22   }
23  
24 < GoogleTron::GoogleTron() : finished(false)
24 > GoogleTron::GoogleTron(const cse::String &sitemap) : working(true), sitemap(sitemap)
25   {
26 +        // XXX: start some threads
27   }
28  
29   GoogleTron::~GoogleTron()
30   {
31 +        // XXX: wait on threads
32 +        
33 +        working = false;
34 +
35 +        // XXX: wait on output thread
36   }
37  
38   int GoogleTron::Output()
39   {
40 <        _S<GzipWriter> gzip(_B("sitemap.gz"));
40 >        _S<GzipWriter> gzip(sitemap);
41          _S<xml::TextWriter> writer(gzip);
42          xml::ScopeElement urlset(writer, _B("urlset"));
43  
44          writer.SetAttribute(_B("xmlns"), _B("http://www.google.com/schemas/sitemap/0.84"));
45  
46 +        do
47 +        {
48 +                Sleep();
49 +
50 +                _synchronized (queueLock)
51 +                        if (queue.size())
52 +                        {
53 +                                xml::ScopeElement url_(writer, _B("url"));
54 +                                const Url &url(queue.front());
55 +
56 +                                {
57 +                                        xml::ScopeElement loc(writer, _B("loc"));
58 +
59 +                                        writer.OutputText(url.GetLocation());
60 +                                }
61 +
62 +                                {
63 +                                        xml::ScopeElement lastmod(writer, _B("lastmod"));
64 +
65 +                                        writer.OutputText(url.GetModified());
66 +                                }
67 +
68 +                                {
69 +                                        xml::ScopeElement changefreq(writer, _B("changefreq"));
70 +
71 +                                        writer.OutputText(url.GetFrequency());
72 +                                }
73 +
74 +                                {
75 +                                        xml::ScopeElement priority(writer, _B("priority"));
76 +
77 +                                        writer.OutputText(url.GetPriority());
78 +                                }
79 +
80 +                                queue.pop();
81 +                        }
82 +        }
83 +        while (working);
84 +
85          return 0;
86   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines