help create events w/ boost

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top