Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-12-12 13:03:54


Roland Schwarz wrote:
> Peter Dimov wrote:
>
>> Yuval Ronen wrote:
>>
>> [...]
>>
>>> If we agree that threads cannot be copied,
>>
>> We don't. More details below.
>>
> Sorry for jumping in between. But I always was wondering what
> "copying a thread" could mean. [...]

It doesn't mean anything. A thread cannot be copied. boost::thread is not a
thread, however.

>> The problem with your reasoning is that the thread object may have
>> been destroyed. Its lifetime is not tied to the lifetime of the
>> thread.
> This is true. But where is the problem? Once I have deleted the thread
> object (not the thread!) I am not
> able to compare it to anything, since the memory is invalid, isn't it?

Well, of course. The problem is that this is an unnecessary limitation.
Since the thread still exists, it should be possible to identify it; and a
requirement that the user should make sure that the boost::thread outlives
its corresponding thread is so 1996.

> As I see it, the demand for thread ID's or references mainly come from
> the attempt to communicate with the thread.

The demand for thread ID's come from the need to _identify_ the thread. In
POSIX terms, every operation that takes a pthread_t uses it to identify the
thread on which it is supposed to operate.

Currently the only identifier provided by the library is boost::thread, and
the only allowed operation on a thread is join.


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