7 #include <beacon/event_loop.hpp>
8 #include <boost/bind.hpp>
9 #include <beacon/reference_countable.hpp>
12 using namespace beacon
;
14 unsigned times_called
= 0;
15 class inv
: public invokable
{
18 inv() : invokable(0) {
25 bool operator==(invokable
const & other
) {
26 return this == &other
;
34 int main(int argc
, char * argv
[]) {
42 beacon::invokable::token_ptr
token(new invocation_token
);
45 //enqueue<void()>::callable<void(*)()>::type fn = enqueue<void()>::call(el, &function, token);
47 //slow - approx. 4x slower
48 enqueue
<void()>::invokable
<void(*)()>::type fn
= enqueue
<void()>::invoke(el
, &function
, token
);
50 boost::xtime start
, end
, now
;
51 boost::xtime_get(&start
, boost::TIME_UTC
);
53 for(int i
= 0; i
< 1000000; i
++) {
58 // boost::xtime_get(&now, boost::TIME_UTC);
60 // boost::thread::sleep(now);
62 // cout << "dequing ";
63 // cout << el.dequeue(token) << " calls" << endl;
67 boost::xtime_get(&end
, boost::TIME_UTC
);
69 double diff
= end
.sec
- start
.sec
+ (end
.nsec
- start
.nsec
) / 1e9
;
71 cout
<< "time: " << diff
<< std::endl
;
72 cout
<< "times called: " << times_called
<< endl
;