J
Joe, G.I.
I'm new to boost and what I'm doing seems very simple, but I can't get
it. I want to store 3 events onto a priority_queue and have them execute
n seconds from the time they were created, n is a randomly generated
amount of time between 0 and 10 seconds.
// create container that holds function objects
priority_queue<boost::function<void (Event)> > pq;
// create 3 events and place in priority_queue
boost::bind(destroy_target, placeholders::_1, 'pq');
boost::bind(destroy_target, placeholders::_1, 'pq');
boost::bind(destroy_target, placeholders::_1, 'pq');
I think I now have 3 function objects on the queue, but I don't know how
to pull the Event object off the queue and check f it's timestamp is
expired, and if so execute the function object that was stored on the queue.
// get the first event off the priority_queue, and if expired, execute
destroy_target().
Event e = pq.top()(Event());
// this is the function I eventually want my event to execute
void destroy_target() { ... }
Any help is greatly appreciated.
it. I want to store 3 events onto a priority_queue and have them execute
n seconds from the time they were created, n is a randomly generated
amount of time between 0 and 10 seconds.
// create container that holds function objects
priority_queue<boost::function<void (Event)> > pq;
// create 3 events and place in priority_queue
boost::bind(destroy_target, placeholders::_1, 'pq');
boost::bind(destroy_target, placeholders::_1, 'pq');
boost::bind(destroy_target, placeholders::_1, 'pq');
I think I now have 3 function objects on the queue, but I don't know how
to pull the Event object off the queue and check f it's timestamp is
expired, and if so execute the function object that was stored on the queue.
// get the first event off the priority_queue, and if expired, execute
destroy_target().
Event e = pq.top()(Event());
// this is the function I eventually want my event to execute
void destroy_target() { ... }
Any help is greatly appreciated.