X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=include%2Fbabeltrace%2Fgraph%2Fmessage-iterator-internal.h;h=00ce436ee8c71645b054cae52b2228f52cb0474e;hb=5b9e151d6a8c0327e67bca1706ef16525d1d319d;hp=bc60424931c050a8f4101b77667ab3d2a9a13ded;hpb=d6e69534ef08a2dd8bff9eb5af1eab63736b3d31;p=babeltrace.git diff --git a/include/babeltrace/graph/message-iterator-internal.h b/include/babeltrace/graph/message-iterator-internal.h index bc604249..00ce436e 100644 --- a/include/babeltrace/graph/message-iterator-internal.h +++ b/include/babeltrace/graph/message-iterator-internal.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,10 +42,10 @@ enum bt_message_iterator_type { }; enum bt_self_component_port_input_message_iterator_state { - /* Iterator is not initialized. */ + /* Iterator is not initialized */ BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED, - /* Iterator is active, not at the end yet, and not finalized. */ + /* Iterator is active, not at the end yet, and not finalized */ BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE, /* @@ -54,19 +54,20 @@ enum bt_self_component_port_input_message_iterator_state { */ BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED, - /* - * Iterator is finalized, but not at the end yet. This means - * that the "next" method can still return queued messages - * before returning the BT_MESSAGE_ITERATOR_STATUS_CANCELED - * status. - */ + /* Iterator is currently being finalized */ + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING, + + /* Iterator is finalized */ BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED, - /* - * Iterator is finalized and ended: the "next" method always - * returns BT_MESSAGE_ITERATOR_STATUS_CANCELED. - */ - BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED_AND_ENDED, + /* Iterator is seeking */ + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_SEEKING, + + /* Iterator did seek, but returned `BT_MESSAGE_ITERATOR_STATUS_AGAIN` */ + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN, + + /* Iterator did seek, but returned error status */ + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR, }; struct bt_message_iterator { @@ -75,6 +76,26 @@ struct bt_message_iterator { GPtrArray *msgs; }; +typedef enum bt_self_message_iterator_status +(*bt_self_component_port_input_message_iterator_next_method)( + void *, bt_message_array_const, uint64_t, uint64_t *); + +typedef enum bt_self_message_iterator_status +(*bt_self_component_port_input_message_iterator_seek_ns_from_origin_method)( + void *, int64_t); + +typedef enum bt_self_message_iterator_status +(*bt_self_component_port_input_message_iterator_seek_beginning_method)( + void *); + +typedef bt_bool +(*bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method)( + void *, int64_t); + +typedef bt_bool +(*bt_self_component_port_input_message_iterator_can_seek_beginning_method)( + void *); + struct bt_self_component_port_input_message_iterator { struct bt_message_iterator base; struct bt_component *upstream_component; /* Weak */ @@ -82,27 +103,16 @@ struct bt_self_component_port_input_message_iterator { struct bt_connection *connection; /* Weak */ struct bt_graph *graph; /* Weak */ - /* - * This hash table keeps the state of a stream as viewed by - * this message iterator. This is used to, in developer - * mode: - * - * * Automatically enqueue "stream begin", "packet begin", - * "packet end", and "stream end" messages depending - * on the stream's state and on the next message returned - * by the upstream component. - * - * * Make sure that, once the message iterator has seen a - * "stream end" message for a given stream, no other - * messages which refer to this stream can be delivered - * by this iterator. - * - * The key (struct bt_stream *) is not owned by this. The - * value is an allocated state structure. - */ - GHashTable *stream_states; + struct { + bt_self_component_port_input_message_iterator_next_method next; + bt_self_component_port_input_message_iterator_seek_ns_from_origin_method seek_ns_from_origin; + bt_self_component_port_input_message_iterator_seek_beginning_method seek_beginning; + bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method can_seek_ns_from_origin; + bt_self_component_port_input_message_iterator_can_seek_beginning_method can_seek_beginning; + } methods; enum bt_self_component_port_input_message_iterator_state state; + GQueue *auto_seek_msgs; void *user_data; }; @@ -119,7 +129,7 @@ struct bt_port_output_message_iterator { }; BT_HIDDEN -void bt_self_component_port_input_message_iterator_finalize( +void bt_self_component_port_input_message_iterator_try_finalize( struct bt_self_component_port_input_message_iterator *iterator); BT_HIDDEN @@ -132,8 +142,6 @@ const char *bt_message_iterator_status_string( enum bt_message_iterator_status status) { switch (status) { - case BT_MESSAGE_ITERATOR_STATUS_CANCELED: - return "BT_MESSAGE_ITERATOR_STATUS_CANCELED"; case BT_MESSAGE_ITERATOR_STATUS_AGAIN: return "BT_MESSAGE_ITERATOR_STATUS_AGAIN"; case BT_MESSAGE_ITERATOR_STATUS_END: @@ -158,10 +166,16 @@ const char *bt_self_component_port_input_message_iterator_state_string( return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE"; case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED: return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED"; + case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING: + return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING"; case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED: return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED"; - case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED_AND_ENDED: - return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED_AND_ENDED"; + case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_SEEKING: + return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_SEEKING"; + case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN: + return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN"; + case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR: + return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR"; default: return "(unknown)"; }