本文整理汇总了C++中set_pollin函数的典型用法代码示例。如果您正苦于以下问题:C++ set_pollin函数的具体用法?C++ set_pollin怎么用?C++ set_pollin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_pollin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zmq_assert
void zmq::pgm_receiver_t::activate_in ()
{
// It is possible that the most recently used decoder
// processed the whole buffer but failed to write
// the last message into the pipe.
if (pending_bytes == 0) {
if (mru_decoder != NULL)
mru_decoder->process_buffer (NULL, 0);
return;
}
zmq_assert (mru_decoder != NULL);
zmq_assert (pending_ptr != NULL);
// Ask the decoder to process remaining data.
size_t n = mru_decoder->process_buffer (pending_ptr, pending_bytes);
pending_bytes -= n;
if (pending_bytes > 0)
return;
// Resume polling.
set_pollin (pipe_handle);
set_pollin (socket_handle);
in_event ();
}
示例2: add_fd
void zmq::pgm_sender_t::plug (io_thread_t *io_thread_, session_base_t *session_)
{
// Alocate 2 fds for PGM socket.
fd_t downlink_socket_fd = retired_fd;
fd_t uplink_socket_fd = retired_fd;
fd_t rdata_notify_fd = retired_fd;
fd_t pending_notify_fd = retired_fd;
encoder.set_msg_source (session_);
// Fill fds from PGM transport and add them to the poller.
pgm_socket.get_sender_fds (&downlink_socket_fd, &uplink_socket_fd,
&rdata_notify_fd, &pending_notify_fd);
handle = add_fd (downlink_socket_fd);
uplink_handle = add_fd (uplink_socket_fd);
rdata_notify_handle = add_fd (rdata_notify_fd);
pending_notify_handle = add_fd (pending_notify_fd);
// Set POLLIN. We wont never want to stop polling for uplink = we never
// want to stop porocess NAKs.
set_pollin (uplink_handle);
set_pollin (rdata_notify_handle);
set_pollin (pending_notify_handle);
// Set POLLOUT for downlink_socket_handle.
set_pollout (handle);
}
示例3: add_fd
void zmq::pgm_sender_t::plug (i_inout *inout_)
{
// Alocate 2 fds for PGM socket.
int downlink_socket_fd = 0;
int uplink_socket_fd = 0;
int rdata_notify_fd = 0;
int pending_notify_fd = 0;
encoder.set_inout (inout_);
// Fill fds from PGM transport and add them to the poller.
pgm_socket.get_sender_fds (&downlink_socket_fd, &uplink_socket_fd,
&rdata_notify_fd, &pending_notify_fd);
handle = add_fd (downlink_socket_fd);
uplink_handle = add_fd (uplink_socket_fd);
rdata_notify_handle = add_fd (rdata_notify_fd);
pending_notify_handle = add_fd (pending_notify_fd);
// Set POLLIN. We wont never want to stop polling for uplink = we never
// want to stop porocess NAKs.
set_pollin (uplink_handle);
set_pollin (rdata_notify_handle);
set_pollin (pending_notify_handle);
// Set POLLOUT for downlink_socket_handle.
set_pollout (handle);
}
示例4: add_fd
void zmq::pgm_receiver_t::plug (i_inout *inout_)
{
// Retrieve PGM fds and start polling.
int socket_fd;
int waiting_pipe_fd;
pgm_socket.get_receiver_fds (&socket_fd, &waiting_pipe_fd);
socket_handle = add_fd (socket_fd);
pipe_handle = add_fd (waiting_pipe_fd);
set_pollin (pipe_handle);
set_pollin (socket_handle);
inout = inout_;
}
示例5: add_fd
void zmq::pgm_receiver_t::plug (io_thread_t *io_thread_, i_inout *inout_)
{
// Retrieve PGM fds and start polling.
fd_t socket_fd = retired_fd;
fd_t waiting_pipe_fd = retired_fd;
pgm_socket.get_receiver_fds (&socket_fd, &waiting_pipe_fd);
socket_handle = add_fd (socket_fd);
pipe_handle = add_fd (waiting_pipe_fd);
set_pollin (pipe_handle);
set_pollin (socket_handle);
inout = inout_;
}
示例6: set_pollin
void xs::stream_engine_t::activate_in ()
{
set_pollin (handle);
// Speculative read.
in_event (s);
}
示例7: set_pollin
void zmq::zmq_engine_t::activate_in ()
{
set_pollin (handle);
// Speculative read.
in_event ();
}
示例8: zmq_assert
void zmq::stream_engine_t::plug (io_thread_t *io_thread_,
session_base_t *session_)
{
zmq_assert (!plugged);
plugged = true;
// Connect to session object.
zmq_assert (!session);
zmq_assert (session_);
session = session_;
socket = session-> get_socket ();
// Connect to I/O threads poller object.
io_object_t::plug (io_thread_);
handle = add_fd (s);
io_enabled = true;
// Send the 'length' and 'flags' fields of the identity message.
// The 'length' field is encoded in the long format.
outpos = greeting_output_buffer;
outpos [outsize++] = 0xff;
put_uint64 (&outpos [outsize], options.identity_size + 1);
outsize += 8;
outpos [outsize++] = 0x7f;
set_pollin (handle);
set_pollout (handle);
// Flush all the data that may have been already received downstream.
in_event ();
}
示例9: zmq_assert
void zmq::udp_engine_t::plug (io_thread_t* io_thread_, session_base_t *session_)
{
zmq_assert (!plugged);
plugged = true;
zmq_assert (!session);
zmq_assert (session_);
session = session_;
// Connect to I/O threads poller object.
io_object_t::plug (io_thread_);
handle = add_fd (fd);
if (send_enabled) {
if (!options.raw_socket) {
out_address = address->resolved.udp_addr->dest_addr ();
out_addrlen = address->resolved.udp_addr->dest_addrlen ();
}
else {
out_address = (sockaddr *) &raw_address;
out_addrlen = sizeof (sockaddr_in);
}
set_pollout (handle);
}
if (recv_enabled) {
int on = 1;
int rc = setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof (on));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert (rc != SOCKET_ERROR);
#else
errno_assert (rc == 0);
#endif
rc = bind (fd, address->resolved.udp_addr->bind_addr (),
address->resolved.udp_addr->bind_addrlen ());
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert (rc != SOCKET_ERROR);
#else
errno_assert (rc == 0);
#endif
if (address->resolved.udp_addr->is_mcast ()) {
struct ip_mreq mreq;
mreq.imr_multiaddr = address->resolved.udp_addr->multicast_ip ();
mreq.imr_interface = address->resolved.udp_addr->interface_ip ();
rc = setsockopt (fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*) &mreq, sizeof (mreq));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert (rc != SOCKET_ERROR);
#else
errno_assert (rc == 0);
#endif
}
set_pollin (handle);
// Call restart output to drop all join/leave commands
restart_output ();
}
}
示例10: set_pollin
// Called when our pipe is reactivated (able to accept more data).
void zmq::udp_receiver_t::restart_input ()
{
// Process any pending data.
if (pending_bytes > 0) {
ssize_t processed_bytes = 0;
// decoder->process_buffer (pending_p, pending_bytes);
// Flush any messages produced by the decoder to the pipe.
session->flush ();
if (processed_bytes < pending_bytes) {
// Some data (still) could not be written to the pipe.
pending_bytes -= processed_bytes;
pending_p += processed_bytes;
// Try again later.
return;
}
// Done with unprocessed data.
pending_bytes = 0;
}
// Reactivate polling.
set_pollin (socket_handle);
// Read any data that might have showed up on the socket in the mean time.
in_event (retired_fd);
}
示例11: zmq_assert
void zmq::stream_engine_t::plug (io_thread_t *io_thread_,
session_base_t *session_)
{
zmq_assert (!plugged);
plugged = true;
// Connect to session object.
zmq_assert (!session);
zmq_assert (session_);
session = session_;
socket = session-> get_socket ();
// Connect to I/O threads poller object.
io_object_t::plug (io_thread_);
handle = add_fd (s);
io_error = false;
if (options.raw_socket) {
// no handshaking for raw sock, instantiate raw encoder and decoders
encoder = new (std::nothrow) raw_encoder_t (out_batch_size);
alloc_assert (encoder);
decoder = new (std::nothrow) raw_decoder_t (in_batch_size);
alloc_assert (decoder);
// disable handshaking for raw socket
handshaking = false;
next_msg = &stream_engine_t::pull_msg_from_session;
process_msg = &stream_engine_t::push_msg_to_session;
if (options.raw_notify) {
// For raw sockets, send an initial 0-length message to the
// application so that it knows a peer has connected.
msg_t connector;
connector.init();
push_msg_to_session (&connector);
connector.close();
session->flush ();
}
}
else {
// start optional timer, to prevent handshake hanging on no input
set_handshake_timer ();
// Send the 'length' and 'flags' fields of the identity message.
// The 'length' field is encoded in the long format.
outpos = greeting_send;
outpos [outsize++] = 0xff;
put_uint64 (&outpos [outsize], options.identity_size + 1);
outsize += 8;
outpos [outsize++] = 0x7f;
}
set_pollin (handle);
set_pollout (handle);
// Flush all the data that may have been already received downstream.
in_event ();
}
示例12: set_pollin
void zmq::udp_engine_t::restart_input ()
{
if (!recv_enabled)
return;
set_pollin (handle);
in_event ();
}
示例13: add_fd
void zmq::pgm_receiver_t::plug (io_thread_t *io_thread_,
session_base_t *session_)
{
// Retrieve PGM fds and start polling.
fd_t socket_fd = retired_fd;
fd_t waiting_pipe_fd = retired_fd;
pgm_socket.get_receiver_fds (&socket_fd, &waiting_pipe_fd);
socket_handle = add_fd (socket_fd);
pipe_handle = add_fd (waiting_pipe_fd);
set_pollin (pipe_handle);
set_pollin (socket_handle);
session = session_;
// If there are any subscriptions already queued in the session, drop them.
drop_subscriptions ();
}
示例14: zmq_assert
void zmq::socks_connecter_t::out_event ()
{
zmq_assert (status == waiting_for_proxy_connection
|| status == sending_greeting
|| status == sending_request);
if (status == waiting_for_proxy_connection) {
const int rc = (int) check_proxy_connection ();
if (rc == -1)
error ();
else {
greeting_encoder.encode (
socks_greeting_t (socks_no_auth_required));
status = sending_greeting;
}
}
else
if (status == sending_greeting) {
zmq_assert (greeting_encoder.has_pending_data ());
const int rc = greeting_encoder.output (s);
if (rc == -1 || rc == 0)
error ();
else
if (!greeting_encoder.has_pending_data ()) {
reset_pollout (handle);
set_pollin (handle);
status = waiting_for_choice;
}
}
else {
zmq_assert (request_encoder.has_pending_data ());
const int rc = request_encoder.output (s);
if (rc == -1 || rc == 0)
error ();
else
if (!request_encoder.has_pending_data ()) {
reset_pollout (handle);
set_pollin (handle);
status = waiting_for_response;
}
}
}
示例15: add_fd
void zmq::udp_receiver_t::plug (io_thread_t *io_thread_,
session_base_t *session_)
{
// Start polling.
socket_handle = add_fd (socket);
set_pollin (socket_handle);
session = session_;
//decoder->set_session (session);
// If there are any subscriptions already queued in the session, drop them.
drop_subscriptions ();
}