- 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_;
+ 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_;
+
+ std::chrono::time_point<std::chrono::steady_clock> create_time_;
+
+ int waiters_;
+ int refno_;
+ const int lossy_;
+
+ std::mutex m_;
+ std::mutex ref_m_;
+ std::condition_variable send_complete_;
+ std::condition_variable send_wait_;