don't remove/add back the socket to the list of inputs monitored by the event loop all the time but just leave it there until the socket is destroyed; this should be beneficial from performance point of view (although hard to measure) and also makes the code simpler

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-12-27 21:56:05 +00:00
parent cf21e2fc0b
commit 7d66cdccd0
2 changed files with 1 additions and 36 deletions

View File

@@ -52,12 +52,7 @@ public:
private:
virtual void DoClose()
{
wxSocketManager * const manager = wxSocketManager::Get();
if ( manager )
{
manager->Uninstall_Callback(this, wxSOCKET_INPUT);
manager->Uninstall_Callback(this, wxSOCKET_OUTPUT);
}
DisableEvents();
close(m_fd);
}
@@ -78,10 +73,6 @@ private:
void DoEnableEvents(bool enable);
// enable or disable events for the given event
void EnableEvent(wxSocketNotify event);
void DisableEvent(wxSocketNotify event);
int Recv_Stream(void *buffer, int size);
int Recv_Dgram(void *buffer, int size);
int Send_Stream(const void *buffer, int size);

View File

@@ -493,9 +493,6 @@ int wxSocketImplUnix::Read(void *buffer, int size)
return -1;
}
/* Disable events during query of socket status */
DisableEvent(wxSOCKET_INPUT);
/* Read the data */
if (m_stream)
ret = Recv_Stream(buffer, size);
@@ -525,9 +522,6 @@ int wxSocketImplUnix::Read(void *buffer, int size)
m_error = wxSOCKET_IOERR;
}
/* Enable events again now that we are done processing */
EnableEvent(wxSOCKET_INPUT);
return ret;
}
@@ -557,15 +551,6 @@ int wxSocketImplUnix::Write(const void *buffer, int size)
{
m_error = wxSOCKET_IOERR;
}
/* Only reenable OUTPUT events after an error (just like WSAAsyncSelect
* in MSW). Once the first OUTPUT event is received, users can assume
* that the socket is writable until a read operation fails. Only then
* will further OUTPUT events be posted.
*/
EnableEvent(wxSOCKET_OUTPUT);
return -1;
}
return ret;
@@ -573,16 +558,6 @@ int wxSocketImplUnix::Write(const void *buffer, int size)
/* Flags */
void wxSocketImplUnix::EnableEvent(wxSocketNotify event)
{
wxSocketManager::Get()->Install_Callback(this, event);
}
void wxSocketImplUnix::DisableEvent(wxSocketNotify event)
{
wxSocketManager::Get()->Uninstall_Callback(this, event);
}
int wxSocketImplUnix::Recv_Stream(void *buffer, int size)
{
int ret;
@@ -690,7 +665,6 @@ int wxSocketImplUnix::Send_Dgram(const void *buffer, int size)
void wxSocketImplUnix::OnStateChange(wxSocketNotify event)
{
DisableEvent(event);
NotifyOnStateChange(event);
if ( event == wxSOCKET_LOST )