-class connection : public aio_callback {
- public:
- struct charbuf {
- charbuf(): buf(NULL), sz(0), solong(0) {}
- charbuf (char *b, int s) : buf(b), sz(s), solong(0){}
- char *buf;
- int sz;
- int solong; //amount of bytes written or read so far
- };
-
- connection(chanmgr *m1, int f1, int lossytest=0);
- ~connection();
-
- int channo() { return fd_; }
- bool isdead();
- void closeconn();
-
- bool send(char *b, int sz);
- void write_cb(int s);
- void read_cb(int s);
-
- void incref();
- void decref();
- int ref();
-
- int compare(connection *another);
- private:
-
- bool readpdu();
- bool writepdu();
-
- chanmgr *mgr_;
- const int fd_;
- bool dead_;
-
- charbuf wpdu_;
- charbuf rpdu_;
-
- struct timeval create_time_;
-
- int waiters_;
- int refno_;
- const int lossy_;
-
- pthread_mutex_t m_;
- pthread_mutex_t ref_m_;
- pthread_cond_t send_complete_;
- pthread_cond_t send_wait_;
-};