本文整理汇总了C++中QTcpSocket::blockSignals方法的典型用法代码示例。如果您正苦于以下问题:C++ QTcpSocket::blockSignals方法的具体用法?C++ QTcpSocket::blockSignals怎么用?C++ QTcpSocket::blockSignals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTcpSocket
的用法示例。
在下文中一共展示了QTcpSocket::blockSignals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void dtkComposerNodeCommunicatorReceive::run(void)
{
if (!d->receiver_source.isEmpty()) {
if (d->receiver_comm.isEmpty() && d->receiver_socket.isEmpty()) {
dtkError() << "Send node at either a socket or a communicator.";
return;
}
d->source = d->receiver_source.data();
d->tag = 0;
if (!d->receiver_tag.isEmpty())
d->tag = d->receiver_tag.data();
d->emitter.clearData();
if (!d->receiver_data.isEmpty()) {
d->emitter.setData(d->receiver_data.variant());
}
if (d->receiver_comm.isEmpty()) {
QTcpSocket *socket = d->receiver_socket.constData();
dtkDebug() << "TCP communicator. Parse message from socket, waiting for tag" << d->tag;
if (d->msg_map.contains(d->tag)) {
dtkDebug() << "msg already received for tag" << d->tag;
// d->emitter.setTwinned(false);
dtkDistributedMessage *msg = d->msg_map.take(d->tag);
d->emitter.setData(msg->content());
// d->emitter.setTwinned(true);
delete msg;
return;
} else {
dtkTrace() << "msg not yet received, wait for data";
}
socket->blockSignals(true); // needed ?
if (!socket->waitForReadyRead(300000)) {
dtkWarn() << "Data not ready in receive for rank " << d->source;
} else {
dtkDistributedMessage msg;
msg.parse(socket);
qlonglong msg_tag = msg.header("Tag").toLongLong();
if (msg_tag == d->tag || d->tag == dtkDistributedCommunicator::ANY_TAG) {
dtkTrace() << "OK, this is the expected tag " << d->tag;
// d->emitter.setTwinned(false);
d->emitter.setData(msg.content());
// d->emitter.setTwinned(true);
if (d->tag == dtkDistributedCommunicator::ANY_TAG)
d->tag = msg_tag;
} else {
//store msg for another call with the right tag
dtkInfo() << "Msg received, but wrong tag, store the msg" << d->tag << msg_tag;
d->msg_map.insert(msg_tag, &msg);
this->run(); // do it again
}
}
socket->blockSignals(false); // needed ?
} else { // MPI
QByteArray array;
dtkDistributedCommunicatorStatus status;
dtkDistributedCommunicator *communicator = d->receiver_comm.constData();
//FIXME:[migration] new transmitter requieres a clone method in object, even if dataTransmission is set to reference
communicator->receive(array, d->source, d->tag, status);
if (d->tag == dtkDistributedCommunicator::ANY_TAG)
d->tag = status.tag();
if (d->source == dtkDistributedCommunicator::ANY_SOURCE)
d->source = status.source();
if (!array.isEmpty()) {
// d->emitter.setTwinned(false);
d->emitter.setData(array);
// d->emitter.setTwinned(true);
} else {
dtkWarn() << "Empty data in receive";
d->emitter.clearData();
}
}
} else {
d->emitter.clearData();
dtkWarn() << "Inputs not specified in receive. Nothing is done";
d->tag = 0;
d->source = 0;
}
d->emitter_source.setData(d->source);
d->emitter_tag.setData(d->tag);
}