Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef XMPP_XMPP_CONNECTION_MANAGER_H 6 : #define XMPP_XMPP_CONNECTION_MANAGER_H 7 : 8 : #include <mutex> 9 : 10 : #include "base/queue_task.h" 11 : #include "io/ssl_server.h" 12 : 13 : class LifetimeActor; 14 : class XmppSession; 15 : 16 : // 17 : // Common class to represent XmppClient and XmppServer 18 : // 19 : class XmppConnectionManager : public SslServer { 20 : public: 21 : XmppConnectionManager(EventManager *evm, 22 : boost::asio::ssl::context::method m, 23 : bool ssl_enabled, bool ssl_handshake_delayed); 24 : 25 : void Shutdown(); 26 : void EnqueueSession(XmppSession *session); 27 : size_t GetSessionQueueSize() const; 28 : virtual LifetimeActor *deleter() = 0; 29 15771 : std::mutex &mutex() const { return mutex_; } 30 : 31 : private: 32 : bool DequeueSession(TcpSessionPtr tcp_session); 33 : void WorkQueueExitCallback(bool done); 34 : 35 : WorkQueue<TcpSessionPtr> session_queue_; 36 : mutable std::mutex mutex_; 37 : 38 : DISALLOW_COPY_AND_ASSIGN(XmppConnectionManager); 39 : }; 40 : 41 : #endif // XMPP_XMPP_CONNECTION_MANAGER_H