#include "string.h"
#include "buffer_tree.h"
#include "error.h"
+#include "sched.h"
struct btr_buffer {
struct list_head node;
/* The children nodes of this btr node are linked together in a list. */
struct list_head children;
+ /* Time of first data transfer. */
+ struct timeval start;
/**
* The input queue is a list of references to btr buffers. Each item on
* the list represents an input buffer which has not been completely
btrn->parent = parent;
btrn->execute = handler;
btrn->context = context;
+ btrn->start.tv_sec = 0;
+ btrn->start.tv_usec = 0;
if (parent)
list_add_tail(&btrn->node, &parent->children);
INIT_LIST_HEAD(&btrn->children);
{
struct btr_node *ch;
+ if (btrn->start.tv_sec == 0)
+ btrn->start = *now;
FOR_EACH_CHILD(ch, btrn) {
struct btr_buffer_reference *br = para_malloc(sizeof(*br));
br->btrb = btrb;
br->consumed = consumed;
list_add_tail(&br->node, &ch->input_queue);
btrb->refcount++;
+ if (ch->start.tv_sec == 0)
+ ch->start = *now;
}
}
}
/* make a new btrb that combines the two buffers and a br to it. */
sz = szs[0] + szs[1];
- //PARA_CRIT_LOG("merging input buffers: (%zu, %zu) -> %zu\n",
- // szs[0], szs[1], sz);
+ PARA_DEBUG_LOG("merging input buffers: (%zu, %zu) -> %zu\n",
+ szs[0], szs[1], sz);
buf = para_malloc(sz);
/* TODO: Avoid this memcopy by introducing btr buffer pool. */
memcpy(buf, bufs[0], szs[0]);
size_t len = btr_next_buffer(btrn, &buf);
if (len >= dest_size)
return;
+ PARA_DEBUG_LOG("input size = %zu < %zu = dest\n", len, dest_size);
if (merge_input(btrn) < 2)
return;
}
}
return 1;
}
+
+void btr_get_node_start(struct btr_node *btrn, struct timeval *tv)
+{
+ *tv = btrn->start;
+}