projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
correction to last commit: Korean and Romanian translations will only be in 2.9.1...
[wxWidgets.git]
/
src
/
common
/
selectdispatcher.cpp
diff --git
a/src/common/selectdispatcher.cpp
b/src/common/selectdispatcher.cpp
index ffcf38717912bd16ad42dec7075fbaf77bb1a761..1365319347931940c1a4d09348e9d957cdf678b3 100644
(file)
--- a/
src/common/selectdispatcher.cpp
+++ b/
src/common/selectdispatcher.cpp
@@
-111,7
+111,7
@@
int wxSelectSets::Select(int nfds, struct timeval *tv)
return select(nfds, &m_fds[Read], &m_fds[Write], &m_fds[Except], tv);
}
return select(nfds, &m_fds[Read], &m_fds[Write], &m_fds[Except], tv);
}
-
void
wxSelectSets::Handle(int fd, wxFDIOHandler& handler) const
+
bool
wxSelectSets::Handle(int fd, wxFDIOHandler& handler) const
{
for ( int n = 0; n < Max; n++ )
{
{
for ( int n = 0; n < Max; n++ )
{
@@
-122,9
+122,11
@@
void wxSelectSets::Handle(int fd, wxFDIOHandler& handler) const
(handler.*ms_handlers[n])();
// callback can modify sets and destroy handler
// this forces that one event can be processed at one time
(handler.*ms_handlers[n])();
// callback can modify sets and destroy handler
// this forces that one event can be processed at one time
- return;
+ return
true
;
}
}
}
}
+
+ return false;
}
// ----------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
@@
-190,8
+192,9
@@
bool wxSelectDispatcher::UnregisterFD(int fd)
return true;
}
return true;
}
-
void
wxSelectDispatcher::ProcessSets(const wxSelectSets& sets)
+
int
wxSelectDispatcher::ProcessSets(const wxSelectSets& sets)
{
{
+ int numEvents = 0;
for ( int fd = 0; fd <= m_maxFD; fd++ )
{
if ( !sets.HasFD(fd) )
for ( int fd = 0; fd <= m_maxFD; fd++ )
{
if ( !sets.HasFD(fd) )
@@
-204,11
+207,14
@@
void wxSelectDispatcher::ProcessSets(const wxSelectSets& sets)
continue;
}
continue;
}
- sets.Handle(fd, *handler);
+ if ( sets.Handle(fd, *handler) )
+ numEvents++;
}
}
+
+ return numEvents;
}
}
-void wxSelectDispatcher::Dispatch(int timeout)
+int wxSelectDispatcher::DoSelect(wxSelectSets& sets, int timeout) const
{
struct timeval tv,
*ptv;
{
struct timeval tv,
*ptv;
@@
-223,24
+229,37
@@
void wxSelectDispatcher::Dispatch(int timeout)
ptv = NULL;
}
ptv = NULL;
}
- wxSelectSets sets = m_sets;
+ int ret = sets.Select(m_maxFD + 1, ptv);
+
+ // TODO: we need to restart select() in this case but for now just return
+ // as if timeout expired
+ if ( ret == -1 && errno == EINTR )
+ ret = 0;
+
+ return ret;
+}
- const int ret = sets.Select(m_maxFD + 1, ptv);
- switch ( ret )
+bool wxSelectDispatcher::HasPending() const
+{
+ wxSelectSets sets(m_sets);
+ return DoSelect(sets, 0) > 0;
+}
+
+int wxSelectDispatcher::Dispatch(int timeout)
+{
+ wxSelectSets sets(m_sets);
+ switch ( DoSelect(sets, timeout) )
{
case -1:
{
case -1:
- if ( errno != EINTR )
- {
- wxLogSysError(_("Failed to monitor I/O channels"));
- }
- break;
+ wxLogSysError(_("Failed to monitor I/O channels"));
+ return -1;
case 0:
// timeout expired without anything happening
case 0:
// timeout expired without anything happening
-
break
;
+
return 0
;
default:
default:
- ProcessSets(sets);
+
return
ProcessSets(sets);
}
}
}
}