Changeset f625817 for lib/libtrace_int.h


Ignore:
Timestamp:
09/11/15 15:00:27 (6 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
322c516
Parents:
8c7490fe
Message:

Reworked callback API and removed old per_msg and reporter functions

Updated tracertstats to use the new callback API.

Extended the callback approach to the reporter thread as well as the per
packet threads.

Added libtrace_callback_set_t structure, which is used to register the
user callback functions.

Added callback functionality for MESSAGE_RESULT (needed now that reporter
threads also do callbacks) and MESSAGE_USER (for user-defined messages). The
MESSAGE_USER callback is essentially the same as the old per_msg function
style.

Updated combiners to use send_message to pass results to the reporter thread.
send_message itself is now no longer static, so that combiners can use it.

Disabled building of tracestats_parallel as it was using the older version
of the callback API. Will update in a future commit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace_int.h

    r2fa43fa rf625817  
    284284};
    285285#define ZERO_USER_CONFIG(config) memset(&config, 0, sizeof(struct user_configuration));
     286
     287struct callback_set {
     288
     289        fn_cb_starting message_starting;
     290        fn_cb_dataless message_stopping;
     291        fn_cb_dataless message_resuming;
     292        fn_cb_dataless message_pausing;
     293        fn_cb_packet message_packet;
     294        fn_cb_result message_result;
     295        fn_cb_first_packet message_first_packet;
     296        fn_cb_tick message_tick_count;
     297        fn_cb_tick message_tick_interval;
     298        fn_cb_usermessage message_user;
     299};
    286300
    287301/** A libtrace input trace
     
    333347        /** The actual freelist */
    334348        libtrace_ocache_t packet_freelist;
    335         /** User defined per_msg function called when a message is ready */
    336         fn_cb_msg per_msg;
    337         /** User defined reporter function entry point */
    338         fn_reporter reporter;
    339349        /** The hasher function */
    340350        enum hasher_types hasher_type;
     
    361371        struct user_configuration config;
    362372        libtrace_combine_t combiner;
    363         struct {
    364                 fn_cb_starting message_starting;
    365                 fn_cb_dataless message_stopping;
    366                 fn_cb_dataless message_resuming;
    367                 fn_cb_dataless message_pausing;
    368                 fn_cb_packet message_packet;
    369                 fn_cb_first_packet message_first_packet;
    370                 fn_cb_tick message_tick_count;
    371                 fn_cb_tick message_tick_interval;
    372         } callbacks;
     373       
     374        /* Set of callbacks to be executed by per packet threads in response
     375         * to various messages. */
     376        struct callback_set *perpkt_cbs;
     377        /* Set of callbacks to be executed by the reporter thread in response
     378         * to various messages. */
     379        struct callback_set *reporter_cbs;
    373380};
    374381
     
    380387libtrace_thread_t * get_thread_table(libtrace_t *libtrace);
    381388
     389
     390void send_message(libtrace_t *trace, libtrace_thread_t *target,
     391                const enum libtrace_messages type,
     392                libtrace_generic_t data, libtrace_thread_t *sender);
    382393
    383394/** A libtrace output trace
Note: See TracChangeset for help on using the changeset viewer.