本文整理汇总了C++中rr_dev::wait_wr_cb方法的典型用法代码示例。如果您正苦于以下问题:C++ rr_dev::wait_wr_cb方法的具体用法?C++ rr_dev::wait_wr_cb怎么用?C++ rr_dev::wait_wr_cb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rr_dev
的用法示例。
在下文中一共展示了rr_dev::wait_wr_cb方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/* What an horrible method - the protocol is so bad flow control
wise we can jam up, and need to be coaxed back into life */
void
rr_dev_kick (rr_dev dev)
{
dev->send_next = 1;
dev->init_send_count = dev->dev_cmdqueue_size - 1;
dev->wait_wr_cb (dev, 1, dev->wait_wr_cl);
}
示例2: while
int
rr_dev_resend (rr_dev dev, unsigned long lineno, const char *reply, size_t nbytes)
{
int resent = 0;
blocknode *node;
/* sent cache slot 0 is most recent */
while (1) {
if (!(node = rr_dev_pop_from_queue (dev, RR_PRIO_SENTCACHE)))
break;
rr_dev_log (dev, RR_DEBUG_HIGH, "pop sent node line %d '%s' (%d bytes)\n",
(int)node->line, node->block, node->blocksize);
if (node->line >= lineno) {
rr_dev_prepend_to_queue (dev, RR_PRIO_RESEND, node);
resent++;
} else { /* put it back and look elsewhere */
rr_dev_prepend_to_queue (dev, RR_PRIO_SENTCACHE, node);
break;
}
}
if (resent == 0) {
/* Perhaps line is in the resend queue, and we got an:
* rs: 3
* rs: 6
* type sequence so try peel forward the resend queue.
*/
while (1) {
if (!(node = rr_dev_pop_from_queue (dev, RR_PRIO_RESEND)))
break;
rr_dev_log (dev, RR_DEBUG_HIGH,
"pop resend node line %d '%s' (%d bytes)\n",
(int)node->line, node->block, node->blocksize);
if (node->line < lineno) {
rr_dev_prepend_to_queue (dev, RR_PRIO_SENTCACHE, node);
resent++;
} else { /* put it back and give up */
rr_dev_prepend_to_queue (dev, RR_PRIO_RESEND, node);
break;
}
}
if (resent == 0) {
rr_dev_log (dev, RR_DEBUG_ALWAYS,
"re-send request for unknown (too old) line %ld from cache size %d\n",
lineno, dev->sendsize[RR_PRIO_SENTCACHE]);
rr_dev_emit_error (dev, RR_E_UNCACHED_RESEND, reply, nbytes);
}
}
dev->send_next = 1;
dev->wait_wr_cb (dev, 1, dev->wait_wr_cl);
return 0;
}
示例3: queue
void
rr_dev_handle_ok (rr_dev dev)
{
int buffered = rr_dev_buffered_lines (dev);
/* Send as many commands as we get ok's */
if (dev->init_send_count > 0)
dev->init_send_count--;
dev->send_next = 1;
if (buffered < dev->dev_cmdqueue_size) {
rr_dev_log (dev, RR_DEBUG_MEDIUM,
"request more %d < %d\n", buffered, dev->dev_cmdqueue_size);
dev->more_cb (dev, dev->more_cl);
}
dev->wait_wr_cb (dev, 1, dev->wait_wr_cl);
if (dev->debug_output > RR_DEBUG_ALWAYS)
{ /* Check the sendsize accounts add up */
int i = 0;
for (i = 0; i < RR_PRIO_COUNT; ++i) {
blocknode *p;
int count = 0;
for (p = dev->sendhead[i]; p; p = p->next) {
if (!p->next && dev->sendtail[i] != p)
rr_dev_log (dev, RR_DEBUG_MEDIUM,
"Error: queue (%d) broken tail pointer %p vs %p\n",
i, p, dev->sendtail[i]);
count++;
}
if (count != dev->sendsize[i])
rr_dev_log (dev, RR_DEBUG_MEDIUM,
"Error: queue (%d) size mismatch: %d vs %d\n",
i, count, dev->sendsize[i]);
}
}
}
示例4: fmtblock
int
rr_dev_handle_writable (rr_dev dev)
{
ssize_t result;
if (dev->sendbuf_fill == 0) {
if (dev->init_send_count <= 0 && !dev->send_next) {
rr_dev_log (dev, RR_DEBUG_MEDIUM,
"writeable - init count is %d, no send_next queue %d resend %d\n",
dev->init_send_count, dev->dev_cmdqueue_size,
dev->sendsize[RR_PRIO_RESEND]);
/* wait until there is space in the device buffer and/or an ok */
dev->wait_wr_cb (dev, 0, dev->wait_wr_cl);
return 0;
}
/* Last block is gone; prepare to send a new block */
int prio;
blocknode *node = NULL;
for (prio = RR_PRIO_COUNT - 1; prio >= 0; --prio) {
if (dev->paused[prio])
continue;
node = dev->sendhead[prio];
if (node) {
/* We have a block to send! Get it ready. */
dev->bytes_sent = 0;
result = fmtblock (dev, node);
if (result < 0) {
/* FIXME: This will confuse code expecting errno to be set */
return result;
}
if (result == 0)
rr_dev_log (dev, RR_DEBUG_ALWAYS,
"unusual error - nothing in block to write\n");
dev->send_next = 0;
dev->sendbuf_fill = result;
dev->sending_prio = prio;
break;
}
}
if (!node) {
/* No data to write */
dev->wait_wr_cb (dev, 0, dev->wait_wr_cl);
return 0;
}
}
/* Perform write */
do {
result = write (dev->fd, dev->sendbuf + dev->bytes_sent, dev->sendbuf_fill - dev->bytes_sent);
} while (result < 0 && errno == EINTR);
if (result < 0)
return result;
if (dev->opt_log_cb)
dev->opt_log_cb (dev, RR_LOG_SEND, dev->sendbuf + dev->bytes_sent,
dev->sendbuf_fill - dev->bytes_sent,
dev->opt_log_cl);
dev->bytes_sent += result;
if (dev->bytes_sent == dev->sendbuf_fill) {
/* We've sent the complete block. */
blocknode *node = rr_dev_pop_from_queue (dev, dev->sending_prio);
if (node->line < 0) {
node->line = dev->lineno;
++(dev->lineno);
}
/* Update sent cache */
assert (node->block != NULL);
rr_dev_prepend_to_queue (dev, RR_PRIO_SENTCACHE, node);
if (dev->sendsize[RR_PRIO_SENTCACHE] > (dev->sentcachesize * 3 / 2))
shrink_sentcache (dev);
/* Indicate that we're ready for the next. */
dev->sendbuf_fill = 0;
}
return result;
}