Cześć ,
Mam problem. Mam taką metodę w klasie
static void metoda( /*...*/ const zmq::message_t &msg )
{
/*...*/
else
{
std::thread thread( []( const zmq::message_t msg )
{
/*...*/
}, /* ??? */ );
thread.detach();
}
}
Jednak nie za bardzo wiem w jaki sposób przekazać msg z parametru metody do wątku. Klasa message_t wygląda tak mniej więcej
class message_t
{
public:
inline message_t ()
{
int rc = zmq_msg_init (&msg);
if (rc != 0)
throw error_t ();
}
inline explicit message_t (size_t size_)
{
int rc = zmq_msg_init_size (&msg, size_);
if (rc != 0)
throw error_t ();
}
template<typename I> message_t(I first, I last):
msg()
{
typedef typename std::iterator_traits<I>::difference_type size_type;
typedef typename std::iterator_traits<I>::pointer pointer_t;
size_type const size_ = std::distance(first, last);
int const rc = zmq_msg_init_size (&msg, size_);
if (rc != 0)
throw error_t ();
std::copy(first, last, static_cast<pointer_t>(zmq_msg_data (&msg)) );
}
inline message_t (void *data_, size_t size_, free_fn *ffn_,
void *hint_ = NULL)
{
int rc = zmq_msg_init_data (&msg, data_, size_, ffn_, hint_);
if (rc != 0)
throw error_t ();
}
inline message_t (message_t &&rhs): msg (rhs.msg)
{
int rc = zmq_msg_init (&rhs.msg);
if (rc != 0)
throw error_t ();
}
inline message_t &operator = (message_t &&rhs) ZMQ_NOTHROW
{
std::swap (msg, rhs.msg);
return *this;
}
inline ~message_t () ZMQ_NOTHROW
{
int rc = zmq_msg_close (&msg);
ZMQ_ASSERT (rc == 0);
}
/*..*/
private:
// Disable implicit message copying, so that users won't use shared
// messages (less efficient) without being aware of the fact.
message_t (const message_t&) ZMQ_DELETED_FUNCTION;
void operator = (const message_t&) ZMQ_DELETED_FUNCTION;
};
Z góry dzięki za pomoce (: