class AsyncMessenger;
+/*
+ * AsyncConnection maintains a logic session between two endpoints. In other
+ * word, a pair of addresses can find the only AsyncConnection. AsyncConnection
+ * will handle with network fault or read/write transactions. If one file
+ * descriptor broken, AsyncConnection will maintain the message queue and
+ * sequence, try to reconnect peer endpoint.
+ */
class AsyncConnection : public Connection {
const static uint64_t IOV_LEN = 1024;
/*
- * This class handles transmission and reception of messages. Generally
- * speaking, there are several major components:
+ * AsyncMessenger is represented for maintaining a set of asynchronous connections,
+ * it may own a bind address and the accepted connections will be managed by
+ * AsyncMessenger.
*
- * - Connection
- * Each logical session is associated with a Connection.
- * - AsyncConnection
- * Each network connection is handled through a AsyncConnection, which handles
- * the input and output of each message. There is normally a 1:1
- * relationship between AsyncConnection and Connection, but logical sessions may
- * get handed off between AsyncConnection when sockets reconnect or during
- * connection races.
- * - IncomingQueue
- * Incoming messages are associated with an IncomingQueue, and there
- * is one such queue associated with each AsyncConnection.
- * - DispatchQueue
- * IncomingQueues get queued in the DispatchQueue, which is responsible
- * for doing a round-robin sweep and processing them via a worker thread.
- * - AsyncMessenger
- * It's the exterior class passed to the external message handler and
- * most of the API details.
- *
- * Lock ordering:
- *
- * AsyncMessenger::lock
- * Pipe::pipe_lock
- * DispatchQueue::lock
- * IncomingQueue::lock
*/
class AsyncMessenger : public SimplePolicyMessenger {
*/
} ;
-#endif /* CEPH_SIMPLEMESSENGER_H */
+#endif /* CEPH_ASYNCMESSENGER_H */
int mask;
};
+/*
+ * EventDriver is a wrap of event mechanisms depends on different OS.
+ * For example, Linux will use epoll(2), BSD will use kqueue(2) and select will
+ * be used for worst condition.
+ */
class EventDriver {
public:
virtual ~EventDriver() {} // we want a virtual destructor!!!
virtual int resize_events(int newsize) = 0;
};
+
+/*
+ * EventCenter maintain a set of file descriptor and handle registered events.
+ *
+ * EventCenter is aimed to used by one thread, other threads access EventCenter
+ * only can use dispatch_event_external method which is protected by lock.
+ */
class EventCenter {
struct FileEvent {
int mask;