提升1.49.0编译问题

时间:2012-11-29 15:07:19

标签: c++ boost message-queue

我尝试用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 = 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");
    }
};

我收到以下错误消息:

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 '<'

似乎你不能在同一个类中同时使用interprocess :: message_queue和interprocess:named_condition。

有什么想法吗?我非常感谢你在这个问题上的帮助。

0 个答案:

没有答案