|
Boost Users : |
Subject: [Boost-users] Why does boost thread copy a functor?
From: Chris Cleeland (chris.cleeland_at_[hidden])
Date: 2012-01-15 19:25:52
I had code similar to the following...
Functor object:
struct Task
{
operator()() { // thread main }
smartfd p;
};
Note that smartfd is a wrapper around a file descriptor. In its dtor it
closes the fd.
Then, elsewhere I set up an instance of Task and spawn it with
boost::thread...
Task t;
t.p = // open file descriptor
boost::thread thr(t);
The spawned thread gets an instance of Task, but it's not the same instance
as from the main.
What is the rationale?
-- Chris Cleeland
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net