1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 * Author: Alexander Larsson <alexl@redhat.com>
23 #include "gasynchelper.h"
27 * SECTION:gasynchelper
28 * @short_description: Asynchronous Helper Functions
30 * @see_also: #GAsyncResult
32 * Provides helper functions for asynchronous operations.
38 _g_win32_overlap_wait_result (HANDLE hfile
,
41 GCancellable
*cancellable
)
44 gboolean result
= FALSE
;
47 #if GLIB_SIZEOF_VOID_P == 8
48 pollfd
[0].fd
= (gint64
)overlap
->hEvent
;
50 pollfd
[0].fd
= (gint
)overlap
->hEvent
;
52 pollfd
[0].events
= G_IO_IN
;
55 if (g_cancellable_make_pollfd (cancellable
, &pollfd
[1]))
59 npoll
= g_poll (pollfd
, num
, -1);
61 /* error out, should never happen */
64 if (g_cancellable_is_cancelled (cancellable
))
66 /* CancelIO only cancels pending operations issued by the
67 * current thread and since we're doing only sync operations,
69 /* CancelIoEx is only Vista+. Since we have only one overlap
70 * operaton on this thread, we can just use: */
71 result
= CancelIo (hfile
);
72 g_warn_if_fail (result
);
75 result
= GetOverlappedResult (overlap
->hEvent
, overlap
, transferred
, FALSE
);
76 if (result
== FALSE
&&
77 GetLastError () == ERROR_IO_INCOMPLETE
&&
78 !g_cancellable_is_cancelled (cancellable
))
83 g_cancellable_release_fd (cancellable
);