|
Boost : |
From: Eric Woodruff (Eric.Woodruff_at_[hidden])
Date: 2002-08-06 13:25:54
Correction:
Change
#ifndef BOOST_DONT_USE_PIMPL
#include <boost/thread/win32_thread_implementation.hpp>
thread::thread (...) {
}
#else
thread::thread (...)
: platformThread (new threads::PlatformSpecificThead (this)) {
}
#endif
To
#ifdef BOOST_DONT_USE_PIMPL
thread::thread (...) {
}
#else
#include <boost/thread/win32_thread_implementation.hpp>
thread::thread (...)
: platformThread (new threads::PlatformSpecificThead (this)) {
}
#endif
I was overcome by my own double negatives.
----- Original Message -----
From: Eric Woodruff
Newsgroups: gmane.comp.lib.boost.devel
Sent: Tuesday, 2002:August:06 1:10 PM
Subject: Platform Neutrality - Users choice to pollute the globalnamespace
Here's another option:
As I suggest before, to use a secondary class with the specific
implementation in it, why not make it a flag that the user can set whether
to use a "PIMPL" or just a normal instance of it. Some people might rather
not have <windows.h> or <pthread.h> include in their dependency hierarchy --
this is after all, one of the key points of the abstraction.
Consider:
// thread.hpp
#ifdef BOOST_POLUTE_HEADER_AND_NAME_SPACE
#define BOOST_DONT_USE_PIMPL
#endif
#include <boost/thread/platform_implementations.hpp>
namespace boost {
class thread {
public:
// ...
private:
#ifdef BOOST_DONT_USE_PIMPL
threads::PlatformSpecificThread platformThread; // i'll address
the pointer vs non-pointer
#else
threads::PlatformSpecificThread* platformThread;
#endif
};
}
// platform impelmentations.hpp
#include <boost/thread/win32_thread_implementation.hpp>
#include <boost/thread/posix_thread_implementation.hpp>
// win32_thread_implementation
#ifdef WIN32
#include <Windows.h>
namespace boost {
namespace threads {
class PlatformSpecificThread {
//...
HANDLE threadHandle;
PlatformSpecificThread* operator-> () { return this; }
// this will keep the code generic between PIMPL and PIMPL-free
};
}
}
#endif
// thread.cpp - win32 version
using boost::thread;
// only the constructor is sentient of the difference.
#ifndef BOOST_DONT_USE_PIMPL
#include <boost/thread/win32_thread_implementation.hpp>
thread::thread (...) {
}
#else
thread::thread (...)
: platformThread (new threads::PlatformSpecificThead (this)) {
}
#endif
// a very trivialized but clean version of join (example only)
thread::join () {
WaitForMultipleObjectsEx (platformThread->Handle,...);
}
_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk