]> git.saurik.com Git - wxWidgets.git/commitdiff
remove m_use_events from Unix wxSocket implementation, we always need asynchronous...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 26 Dec 2008 20:20:46 +0000 (20:20 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 26 Dec 2008 20:20:46 +0000 (20:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57569 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/private/socket.h
include/wx/unix/private/sockunix.h
src/common/socket.cpp
src/unix/sockunix.cpp

index 674edfaa822c214177fda13051a81c7af74ebc75..d953f082ec14e94dd3a837cabfb89020a80a5a70 100644 (file)
@@ -267,9 +267,6 @@ public:
     // named) OnRequest() method
     void NotifyOnStateChange(wxSocketNotify event);
 
-    // FIXME: this one probably isn't needed here at all
-    virtual void Notify(bool WXUNUSED(notify)) { }
-
     // TODO: make these fields protected and provide accessors for those of
     //       them that wxSocketBase really needs
 //protected:
index 14bc5e5a1c89c486847a45fd402dbd78144f317f..a10488848810d9e35c27668ad022579893cadb3a 100644 (file)
@@ -26,7 +26,6 @@ public:
         m_fds[0] =
         m_fds[1] = -1;
 
-        m_use_events = false;
         m_enabledCallbacks = 0;
     }
 
@@ -35,8 +34,6 @@ public:
 
     int Read(void *buffer, int size);
     int Write(const void *buffer, int size);
-    //attach or detach from main loop
-    void Notify(bool flag);
 
     // wxFDIOHandler methods
     virtual void OnReadWaiting();
@@ -73,27 +70,16 @@ private:
         EnableEvents();
     }
 
-    // enable or disable notifications for socket input/output events but only
-    // if m_use_events is true; do nothing otherwise
-    virtual void EnableEvents()
-    {
-        if ( m_use_events )
-            DoEnableEvents(true);
+    // enable or disable notifications for socket input/output events
+    void EnableEvents() { DoEnableEvents(true); }
+    void DisableEvents() { DoEnableEvents(false);
     }
 
-    void DisableEvents()
-    {
-        if ( m_use_events )
-            DoEnableEvents(false);
-    }
-
-    // really enable or disable socket input/output events, regardless of
-    // m_use_events value
+    // really enable or disable socket input/output events
     void DoEnableEvents(bool enable);
 
 
-    // enable or disable events for the given event if m_use_events; do nothing
-    // otherwise
+    // enable or disable events for the given event
     //
     // notice that these functions also update m_detected: EnableEvent() clears
     // the corresponding bit in it and DisableEvent() sets it
@@ -107,9 +93,6 @@ private:
 
 
 protected:
-    // true if socket should fire events
-    bool m_use_events;
-
     // descriptors for input and output event notification channels associated
     // with the socket
     int m_fds[2];
index 2c916540406f634cc3b97f6713b040623c3b430f..221af68ee49af82acad2a54f033f33b7a9ab4b2c 100644 (file)
@@ -667,7 +667,7 @@ bool wxSocketBase::Destroy()
     // Shutdown and close the socket
     Close();
 
-    // Supress events from now on
+    // Suppress events from now on
     Notify(false);
 
     // schedule this object for deletion
@@ -1540,8 +1540,6 @@ void wxSocketBase::OnRequest(wxSocketNotify notification)
 void wxSocketBase::Notify(bool notify)
 {
     m_notify = notify;
-    if (m_impl)
-        m_impl->Notify(notify);
 }
 
 void wxSocketBase::SetNotify(wxSocketEventFlags flags)
@@ -1632,7 +1630,6 @@ wxSocketServer::wxSocketServer(const wxSockAddress& addr_man,
     }
 
     // Setup the socket as server
-    m_impl->Notify(m_notify);
     m_impl->SetLocal(addr_man.GetAddress());
 
     if (GetFlags() & wxSOCKET_REUSEADDR) {
@@ -1818,9 +1815,6 @@ bool wxSocketClient::DoConnect(const wxSockAddress& addr_man,
     m_impl->SetPeer(addr_man.GetAddress());
     const wxSocketError err = m_impl->CreateClient();
 
-    //this will register for callbacks - must be called after m_impl->m_fd was initialized
-    m_impl->Notify(m_notify);
-
     if (err != wxSOCKET_NOERROR)
     {
         if (err == wxSOCKET_WOULDBLOCK)
@@ -1879,7 +1873,6 @@ wxDatagramSocket::wxDatagramSocket( const wxSockAddress& addr,
     if (!m_impl)
         return;
 
-    m_impl->Notify(m_notify);
     // Setup the socket as non connection oriented
     m_impl->SetLocal(addr.GetAddress());
     if (flags & wxSOCKET_REUSEADDR)
index c56accdc7acf736c56c982bdfea279a8f366d50a..bfe81ba066f73ca7160ba5602c7a0b991ecf929d 100644 (file)
@@ -535,20 +535,10 @@ wxSocketImpl *wxSocketImplUnix::WaitConnection(wxSocketBase& wxsocket)
 #else
   ioctl(connection->m_fd, FIONBIO, &arg);
 #endif
-  if (m_use_events)
-    connection->Notify(true);
 
   return connection;
 }
 
-void wxSocketImplUnix::Notify(bool flag)
-{
-    if (flag == m_use_events)
-        return;
-    m_use_events = flag;
-    DoEnableEvents(flag);
-}
-
 void wxSocketImplUnix::DoEnableEvents(bool flag)
 {
     wxSocketManager * const manager = wxSocketManager::Get();
@@ -672,12 +662,9 @@ int wxSocketImplUnix::Read(void *buffer, int size)
     if ((ret == 0) && m_stream)
     {
       /* Make sure wxSOCKET_LOST event gets sent and shut down the socket */
-      if (m_use_events)
-      {
-        m_detected = wxSOCKET_LOST_FLAG;
-        OnReadWaiting();
-        return 0;
-      }
+      m_detected = wxSOCKET_LOST_FLAG;
+      OnReadWaiting();
+      return 0;
     }
     else if (ret == -1)
     {
@@ -754,20 +741,14 @@ int wxSocketImplUnix::Write(const void *buffer, int size)
 
 void wxSocketImplUnix::EnableEvent(wxSocketNotify event)
 {
-    if (m_use_events)
-    {
-        m_detected &= ~(1 << event);
-        wxSocketManager::Get()->Install_Callback(this, event);
-    }
+    m_detected &= ~(1 << event);
+    wxSocketManager::Get()->Install_Callback(this, event);
 }
 
 void wxSocketImplUnix::DisableEvent(wxSocketNotify event)
 {
-    if (m_use_events)
-    {
-        m_detected |= (1 << event);
-        wxSocketManager::Get()->Uninstall_Callback(this, event);
-    }
+    m_detected |= (1 << event);
+    wxSocketManager::Get()->Uninstall_Callback(this, event);
 }
 
 int wxSocketImplUnix::Recv_Stream(void *buffer, int size)