11 |
|
Publisher::Publisher(const std::set<Buddy>& buddies, const Database& database, bool start) : buddies(buddies), |
12 |
|
database(database), start(start) |
13 |
|
{ |
14 |
< |
if (start) publisher.Spawn(etl::Bind<0>(&Publisher::publish, this)); |
14 |
> |
if (start) publish(); |
15 |
|
} |
16 |
|
|
17 |
< |
int Publisher::publish() |
18 |
< |
{ |
19 |
< |
cerr << bright << green << "Started publisher daemon at " << Stamp() |
20 |
< |
<< ".\n" << reset; |
21 |
< |
|
22 |
< |
while (true) |
23 |
< |
{ |
24 |
< |
Stamp now, next(now + Hour(1)); |
25 |
< |
api::Thread thread(etl::Bind<0>(&Publisher::update, this)); |
26 |
< |
|
27 |
< |
next.setSeconds(0); |
28 |
< |
next.setMinutes(0); |
29 |
< |
|
30 |
< |
if (Zoe::debug) cerr << "now = " << now << "\nnext = " << next << '\n'; |
31 |
< |
|
32 |
< |
while (now < next - Minute(1)) |
33 |
< |
{ |
34 |
< |
sleep(Minute(1)); |
35 |
< |
|
36 |
< |
now = Stamp(); |
37 |
< |
} |
38 |
< |
|
39 |
< |
while (now < next) |
40 |
< |
{ |
41 |
< |
sleep(1); |
42 |
< |
|
43 |
< |
now = Stamp(); |
44 |
< |
} |
45 |
< |
|
46 |
< |
thread.Join(); |
47 |
< |
} |
48 |
< |
} |
49 |
< |
|
50 |
< |
int Publisher::update() |
17 |
> |
void Publisher::publish() |
18 |
|
{ |
19 |
|
cerr << bright << yellow << "Started updating feeds at " << Stamp() |
20 |
|
<< ".\n" << reset; |