2down votefavorite |
I tried to compile this boost dependent class with VS2008 and VS2010 (error lines are in
bold) #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 = new SafeShardQueue(); boost::interprocess::create_only_t open_create_type;
std::stringstream ss; try { tmp->msgs.reset(new boost::interprocess::message_queue(open_create_type, "message_queue", 256, 1024)); 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")); } catch (const boost::interprocess::interprocess_exception& e) { ss << e.what(); } return tmp; } static void remove() { boost::interprocess::message_queue::remove("message_queue"); boost::interprocess::named_mutex::remove("shared_queue_mutex"); boost::interprocess::named_condition::remove("data_avail_condition"); boost::interprocess::named_condition::remove("queue_empty_condition"); } }; I got the following error message: 1>\boost\boost\interprocess\ipc\message_queue.hpp(254) : error C2039: 'priority_functor' : is not a member of 'boost::interprocess::ipcdetail::ipcdetail' 1>\boost\boost\interprocess\ipc\message_queue.hpp(425) : see reference to class template instantiation 'boost::interprocess::ipcdetail::mq_hdr_t<VoidPointer>' being compiled 1> with 1> [ 1> VoidPointer=boost::interprocess::offset_ptr<void> 1> ] 1>\boost\boost\interprocess\ipc\message_queue.hpp(425) : while compiling class template member function 'unsigned int boost::interprocess::message_queue_t<VoidPointer>::get_mem_size(unsigned int,unsigned int)' 1> with 1> [ 1> VoidPointer=boost::interprocess::offset_ptr<void> 1> ] 1>\boost\boost\interprocess\ipc\message_queue.hpp(465) : while compiling class template member function 'boost::interprocess::message_queue_t<VoidPointer>::message_queue_t(boost::interprocess::open_only_t,const char *)' 1> with 1> [ 1> VoidPointer=boost::interprocess::offset_ptr<void> 1> ] 1>\**sharedqueue.h(42)** : see reference to class template instantiation 'boost::interprocess::message_queue_t<VoidPointer>' being compiled 1> with 1> [ 1> VoidPointer=boost::interprocess::offset_ptr<void> 1> ] 1>\boost\boost\interprocess\ipc\message_queue.hpp(254) : error C2955: 'boost::interprocess::ipcdetail::priority_functor' : use of class template requires template argument list 1>\boost\boost\interprocess\ipc\message_queue.hpp(209) : see declaration of 'boost::interprocess::ipcdetail::priority_functor' 1>\boost\boost\interprocess\ipc\message_queue.hpp(254) : error C2143: syntax error : missing ',' before '<' It seems that you cannot use both interprocess::message_queue and interprocess:named_condition in the same class. Any ideas? I would greatly appreciate your help in this issue. Best Regards, Vladimir |