blob: 715a74df00d0ca4c5cebf4dfd5558f738b759a08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include "bu/minicron.h"
#include "bu/sio.h"
#include <unistd.h>
using namespace Bu;
Bu::MiniCron mCron;
void job0( Bu::MiniCron::Job &job )
{
sio << time( NULL ) << ": job0( id = " << job.getId() << ", count = "
<< job.getRunCount() << ")" << sio.nl;
}
void job1( Bu::MiniCron::Job &job )
{
sio << time( NULL ) << ": job1( id = " << job.getId() << ", count = "
<< job.getRunCount() << ")" << sio.nl;
mCron.removeJob( 4 );
}
void job2( Bu::MiniCron::Job &job )
{
sio << time( NULL ) << ": job2( id = " << job.getId() << ", count = "
<< job.getRunCount() << ")" << sio.nl;
}
void job3( Bu::MiniCron::Job &job )
{
sio << time( NULL ) << ": job3( id = " << job.getId() << ", count = "
<< job.getRunCount() << ")" << sio.nl;
}
int main()
{
mCron.addJob( slot( &job0 ), MiniCron::TimerInterval( time(NULL)+3, 5 ) );
mCron.addJob( slot( &job1 ), MiniCron::TimerInterval( time(NULL)+10, 8 ) );
mCron.addJob( slot( &job2 ), MiniCron::TimerBasic("weekly wed 17") );
mCron.addJob( slot( &job3 ), MiniCron::TimerInterval( time(NULL)+1, 2 ) );
sio << time( NULL ) << ": Program started." << sio.nl;
for(;;)
{
usleep( 50000 );
mCron.poll();
}
return 0;
}
|