Class output_packet : public tbb::filter

The filter class output_packet (Example 11-45) writes each packet from a packet structure to the output file.

Example 11-45. Filter to output a packet

class output_packet : public tbb::filter {
    ostream& out_file;
public:
    output_packet (ofstream& file) : out_file (file), filter (true) {}
    void* operator() (void* item) {
        packet_trace* packet = static_cast<packet_trace*> (item);
        out_file << *packet;
        delete packet;
        return NULL;
    }
};

Get Intel Threading Building Blocks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.