我尝试用VS2008编译这个与boost相关的类(错误行是/**/):
#include <boost/interprocess/ipc/message_queue.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/sync/named_mutex.hpp>
#include <boost/interprocess/sync/named_condition.hpp>
struct SafeShardQueue
{
typedef boost::interprocess::scoped_lock<boost::interprocess::named_mutex> scoped_mutex;
SafeShardQueue()//:
{
}
~SafeShardQueue()
{
remove();
}
void wait_msg()
{
scoped_mutex locker(*mu);
data_avail_condition->wait(locker);
}
void wait_space()
{
scoped_mutex locker(*mu);
queue_empty_condition->wait(locker);
}
boost::shared_ptr<boost::interprocess::message_queue> msgs;
boost::shared_ptr<boost::interprocess::named_condition> data_avail_condition;
boost::shared_ptr<boost::interprocess::named_mutex> mu;
boost::shared_ptr<boost::interprocess::named_condition> queue_empty_condition;
static SafeShardQueue* open()
{
SafeShardQueue* tmp = new SafeShardQueue();
boost::interprocess::open_only_t open_create_type;
/***/tmp->msgs.reset(new boost::interprocess::message_queue (open_create_type, "message_queue"));**
tmp->mu.reset(new boost::interprocess::named_mutex(open_create_type, "shared_queue_mutex"));
tmp->data_avail_condition .reset(new boost::interprocess::named_condition(open_create_type, "data_avail_condition"));
tmp->queue_empty_condition .reset(new boost::interprocess::named_condition(open_create_type, "queue_empty_condition"));
return tmp;
}
static SafeShardQueue* create()
{
remove();
SafeShardQueue* tmp …Run Code Online (Sandbox Code Playgroud)