On Sep 19, 2012, at 12:46 AM, [email protected] wrote:
> Hello,
>
> When compiling the thrift template on OSX, I end up with the following error :
>
> ......../thrift/concurrency/BoostThreadFactory.cpp:102:11: error: no viable
> conversion from 'boost::thread::id' to 'Thread::id_t' (aka 'unsigned long
> long')
> return thread_.get() ? thread_->get_id() : boost::thread::id();
>
> I test the compilation process with 0.8 / 0.9 / and dev brach without
> success. I pretty sure it is an error on my side, but I have no idea which
> one. The boost library I used is from the mac port repository.
>
> Thanks for your help,
> Regards,
> Christophe.
Hi Christophe,
I hoped someone with knowledge of the current implementation would respond, but
since that hasn't happened, I'll tell you what I know about this.
When I wrote my implementation that used Boost::thread, I had to write this
function as part of a BthreadThread class that inherited from Thread:
Thread::id_t getId() {
// The Boost::thread implementation returns a thread_id class.
// This is the only way to extract the actual value it carries, which is
what a Thread::id_t
// wants to be. In their Windows implementation, get_id() just returns an
int, so we wouldn't
// need this junk.
std::stringstream ios;
// This needs to be a pointer because on a *nix system,
this_thread::get_id()
// returns an object that defines operator<< to write the pthread_t to the
stream,
// and it's a pointer, so it gets formatted as hex and we can't change that
by
// inserting a dec manipulator. So when we read out of the stream, we need
to
// read into something for which a hex format makes sense.
void *numericId;
// If this is called before start(), we're hosed
assert (bthread_);
ios << bthread_->get_id();
ios >> numericId;
// And, of course, static_cast can't be used to convert from void* to the
integer type.
return (Thread::id_t)numericId;
}
But that's about all I can tell you.
- Rush