create the single global IO dispatcher in wxFDIODispatcher; don't use wxSelectDispatcher in wxGSocket as the global dispatcher may be of a different type (modified patch 1733626)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47471 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-07-14 20:18:38 +00:00
parent 7523de907d
commit 5e1eac149f
10 changed files with 121 additions and 107 deletions

View File

@@ -23,7 +23,6 @@
#include "wx/unix/private/epolldispatcher.h"
#include "wx/unix/private.h"
#include "wx/module.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
@@ -35,8 +34,6 @@
#define wxEpollDispatcher_Trace wxT("epolldispatcher")
static wxEpollDispatcher *gs_epollDispatcher = NULL;
// ============================================================================
// implementation
// ============================================================================
@@ -75,13 +72,24 @@ static uint32_t GetEpollMask(int flags, int fd)
// wxEpollDispatcher
// ----------------------------------------------------------------------------
wxEpollDispatcher::wxEpollDispatcher()
/* static */
wxEpollDispatcher *wxEpollDispatcher::Create()
{
m_epollDescriptor = epoll_create(1024);
if ( m_epollDescriptor == -1 )
int epollDescriptor = epoll_create(1024);
if ( epollDescriptor == -1 )
{
wxLogSysError(_("Failed to create epoll descriptor"));
return NULL;
}
return new wxEpollDispatcher(epollDescriptor);
}
wxEpollDispatcher::wxEpollDispatcher(int epollDescriptor)
{
wxASSERT_MSG( epollDescriptor != -1, _T("invalid descriptor") );
m_epollDescriptor = epollDescriptor;
}
bool wxEpollDispatcher::RegisterFD(int fd, wxFDIOHandler* handler, int flags)
@@ -175,37 +183,4 @@ void wxEpollDispatcher::Dispatch(int timeout)
}
}
/* static */
wxEpollDispatcher *wxEpollDispatcher::Get()
{
if ( !gs_epollDispatcher )
{
gs_epollDispatcher = new wxEpollDispatcher;
if ( !gs_epollDispatcher->IsOk() )
{
delete gs_epollDispatcher;
gs_epollDispatcher = NULL;
}
}
return gs_epollDispatcher;
}
// ----------------------------------------------------------------------------
// wxEpollDispatcherModule
// ----------------------------------------------------------------------------
class wxEpollDispatcherModule : public wxModule
{
public:
wxEpollDispatcherModule() { }
virtual bool OnInit() { return true; }
virtual void OnExit() { wxDELETE(gs_epollDispatcher); }
DECLARE_DYNAMIC_CLASS(wxEpollDispatcherModule)
};
IMPLEMENT_DYNAMIC_CLASS(wxEpollDispatcherModule, wxModule)
#endif // wxUSE_EPOLL_DISPATCHER