condition_variable Event::m_EventAvailable;
mutex Event::m_Mutex;
-Event::Event(const function<void ()>& callback)
+Event::Event(const Event::Callback& callback)
: m_Callback(callback)
{ }
}
}
-void Event::Post(const function<void ()>& callback)
+void Event::Post(const Event::Callback& callback)
{
if (Application::IsMainThread()) {
callback();
m_EventAvailable.notify_all();
}
}
+
class I2_BASE_API Event
{
public:
+ typedef function<void ()> Callback;
+
static void ProcessEvents(const system_time& wait_until);
- static void Post(const function<void ()>& callback);
+ static void Post(const Callback& callback);
private:
- Event(const function<void ()>& callback);
+ Event(const Callback& callback);
- function<void ()> m_Callback;
+ Callback m_Callback;
static vector<Event> m_Events;
static condition_variable m_EventAvailable;
* Constructor for the FIFO class.
*/
FIFO::FIFO(void)
-{
- m_Buffer = NULL;
- m_DataSize = 0;
- m_AllocSize = 0;
- m_Offset = 0;
-}
+ : m_Buffer(NULL), m_DataSize(0), m_AllocSize(0), m_Offset(0)
+{ }
/**
* Destructor for the FIFO class.
* Constructor for the TcpServer class.
*/
TcpServer::TcpServer(void)
-{
- m_ClientFactory = boost::bind(&TcpClientFactory, RoleInbound);
-}
+ : m_ClientFactory(boost::bind(&TcpClientFactory, RoleInbound))
+{ }
/**
* Sets the client factory.
*
* @param clientFactory The client factory function.
*/
-void TcpServer::SetClientFactory(function<TcpClient::Ptr(SOCKET)> clientFactory)
+void TcpServer::SetClientFactory(const TcpServer::ClientFactory& clientFactory)
{
m_ClientFactory = clientFactory;
}
*
* @returns The client factory function.
*/
-function<TcpClient::Ptr(SOCKET)> TcpServer::GetFactoryFunction(void) const
+TcpServer::ClientFactory TcpServer::GetFactoryFunction(void) const
{
return m_ClientFactory;
}
Event::Post(boost::bind(boost::ref(OnNewClient), GetSelf(), client));
}
+
typedef shared_ptr<TcpServer> Ptr;
typedef weak_ptr<TcpServer> WeakPtr;
+ typedef function<TcpClient::Ptr(SOCKET)> ClientFactory;
+
TcpServer(void);
- void SetClientFactory(function<TcpClient::Ptr(SOCKET)> function);
- function<TcpClient::Ptr(SOCKET)> GetFactoryFunction(void) const;
+ void SetClientFactory(const ClientFactory& function);
+ ClientFactory GetFactoryFunction(void) const;
void Listen(void);
virtual void HandleReadable(void);
private:
- function<TcpClient::Ptr(SOCKET)> m_ClientFactory;
+ ClientFactory m_ClientFactory;
};
}
* Constructor for the Timer class.
*/
Timer::Timer(void)
-{
- m_Interval = 0;
-}
+ : m_Interval(0)
+{ }
/**
* Calls expired timers and returned when the next wake-up should happen.
* @param role The role of the client.
* @param sslContext The SSL context for the client.
*/
-TlsClient::TlsClient(TcpClientRole role, shared_ptr<SSL_CTX> sslContext) : TcpClient(role)
-{
- m_SSLContext = sslContext;
- m_BlockRead = false;
- m_BlockWrite = false;
-}
+TlsClient::TlsClient(TcpClientRole role, shared_ptr<SSL_CTX> sslContext)
+ : TcpClient(role), m_SSLContext(sslContext),
+ m_BlockRead(false), m_BlockWrite(false)
+{ }
void TlsClient::Start(void)
{
DynamicObject::Ptr object = DynamicObject::GetObject(type, name);
+ // TODO: sanitize update, disallow __local
+
if (!object) {
object = DynamicObject::Create(type, update);