Создание потоков
От: darkserj  
Дата: 05.12.05 13:14
Оценка:
не получается запустить потоки в которых есть noncopyable члены (condition, mutex)

    class worker {
public:
        worker(int index):m_index(index) {}
        void push_socket(int s) { m_sock.attach(s); ready.notify_one();}
        void operator ()() {
            boost::mutex::scoped_lock l(lock);
            ready.wait(l);
            std::cout << "Thread: " << m_index << " run" << std::endl;
            std::cout << "Thread: " << m_index << " done" << std::endl;
        }
protected:
        int m_index;
        boost::condition ready;
        boost::mutex lock;
    };
};


void server::create_workers(int count) {
    for(int i=0;i<count;i++) {
        boost::shared_ptr<worker> w(new worker(i));
        workers.push_back(w);
        const ia::worker &wor = *(workers[i].get());
        threads.create_thread(wor);
    }
}


как правильно поступить?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.