mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-23 22:16:16 +01:00
gsocket windows: check event before calling WSAEnumNetworkEvents
The WSAEnumNetworkEvents API is called every time the socket needs to be checked for status changes. Doing this in an application with several sockets could generate a high cpu usage since this call is done for each socket at each iteration of the main loop. Since there is also a WSAEvent that gets signaled when there is a change in the status of the socket, checking its status and calling the WSAEnumNetworkEvents API only if the event is signaled, can reduce the overall cpu usage.
This commit is contained in:
parent
c09ffca226
commit
cfdb60d11d
@ -4107,9 +4107,8 @@ update_condition_unlocked (GSocket *socket)
|
||||
GIOCondition condition;
|
||||
|
||||
if (!socket->priv->closed &&
|
||||
WSAEnumNetworkEvents (socket->priv->fd,
|
||||
socket->priv->event,
|
||||
&events) == 0)
|
||||
(WSAWaitForMultipleEvents (1, &socket->priv->event, FALSE, 0, FALSE) == WSA_WAIT_EVENT_0) &&
|
||||
(WSAEnumNetworkEvents (socket->priv->fd, socket->priv->event, &events) == 0))
|
||||
{
|
||||
socket->priv->current_events |= events.lNetworkEvents;
|
||||
if (events.lNetworkEvents & FD_WRITE &&
|
||||
|
Loading…
Reference in New Issue
Block a user