Try blocking_queue and boost thread.