summaryrefslogtreecommitdiff
path: root/docs/tutorials/015/Compressor.h
blob: 4aaa83144ed54b2bbb06e18909e2f9771bdf7529 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

// $Id$

#ifndef COMPRESSOR_H
#define COMPRESSOR_h

#include "Protocol_Task.h"

/* A reallly dumb compression object.  (It actually adds 3 bytes to
   every message block.)
*/
class Compressor : public Protocol_Task
{
public:

    typedef Protocol_Task inherited;

        // I've given you the option of creating this task derivative
        // with a number of threads.  In retro-spect that really isn't
        // a good idea.  Most client/server systems rely on requests
        // and responses happening in a predicatable order.  Introduce
        // a thread pool and message queue and that ordering goes
        // right out the window.  In other words:  Don't ever use the
        // constructor parameter!
    Compressor( int _thr_count = 0 );

    ~Compressor(void);

protected:

        // This is called when the compressor is on the downstream
        // side.  We'll take the message, compress it and move it
        // along to the next module.
     int send(ACE_Message_Block *message,
              ACE_Time_Value *timeout);

        // This one is called on the upstream side.  No surprise:  we
        // decompress the data and send it on up the stream.
     int recv(ACE_Message_Block *message,
              ACE_Time_Value *timeout);
};

#endif // COMPRESSOR_H