LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2013 The Go Authors. All rights reserved. | 1 // Copyright 2013 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "runtime.h" | 5 #include "runtime.h" |
6 #include "defs_GOOS_GOARCH.h" | 6 #include "defs_GOOS_GOARCH.h" |
7 #include "os_GOOS.h" | 7 #include "os_GOOS.h" |
8 | 8 |
9 #define DWORD_MAX 0xffffffff | 9 #define DWORD_MAX 0xffffffff |
10 | 10 |
11 #pragma dynimport runtime·CreateIoCompletionPort CreateIoCompletionPort "kernel3
2.dll" | 11 #pragma dynimport runtime·CreateIoCompletionPort CreateIoCompletionPort "kernel3
2.dll" |
12 #pragma dynimport runtime·GetQueuedCompletionStatus GetQueuedCompletionStatus "k
ernel32.dll" | 12 #pragma dynimport runtime·GetQueuedCompletionStatus GetQueuedCompletionStatus "k
ernel32.dll" |
13 | 13 |
14 extern void *runtime·CreateIoCompletionPort; | 14 extern void *runtime·CreateIoCompletionPort; |
15 extern void *runtime·GetQueuedCompletionStatus; | 15 extern void *runtime·GetQueuedCompletionStatus; |
16 | 16 |
17 #define INVALID_HANDLE_VALUE ((uintptr)-1) | 17 #define INVALID_HANDLE_VALUE ((uintptr)-1) |
18 | 18 |
19 // net_anOp must be the same as beginning of net.anOp. Keep these in sync. | 19 // net_op must be the same as beginning of net.operation. Keep these in sync. |
20 typedef struct net_anOp net_anOp; | 20 typedef struct net_op net_op; |
21 struct net_anOp | 21 struct net_op |
22 { | 22 { |
23 // used by windows | 23 // used by windows |
24 Overlapped o; | 24 Overlapped o; |
25 // used by netpoll | 25 // used by netpoll |
26 uintptr runtimeCtx; | 26 uintptr runtimeCtx; |
27 int32 mode; | 27 int32 mode; |
28 int32 errno; | 28 int32 errno; |
29 uint32 qty; | 29 uint32 qty; |
30 }; | 30 }; |
31 | 31 |
(...skipping 27 matching lines...) Expand all Loading... |
59 return 0; | 59 return 0; |
60 } | 60 } |
61 | 61 |
62 // Polls for completed network IO. | 62 // Polls for completed network IO. |
63 // Returns list of goroutines that become runnable. | 63 // Returns list of goroutines that become runnable. |
64 G* | 64 G* |
65 runtime·netpoll(bool block) | 65 runtime·netpoll(bool block) |
66 { | 66 { |
67 uint32 wait, qty, key; | 67 uint32 wait, qty, key; |
68 int32 mode, errno; | 68 int32 mode, errno; |
69 » net_anOp *o; | 69 » net_op *o; |
70 G *gp; | 70 G *gp; |
71 | 71 |
72 if(iocphandle == INVALID_HANDLE_VALUE) | 72 if(iocphandle == INVALID_HANDLE_VALUE) |
73 return nil; | 73 return nil; |
74 gp = nil; | 74 gp = nil; |
75 retry: | 75 retry: |
76 o = nil; | 76 o = nil; |
77 errno = 0; | 77 errno = 0; |
78 qty = 0; | 78 qty = 0; |
79 wait = INFINITE; | 79 wait = INFINITE; |
(...skipping 23 matching lines...) Expand all Loading... |
103 runtime·printf("netpoll: GetQueuedCompletionStatus returned inva
lid mode=%d\n", mode); | 103 runtime·printf("netpoll: GetQueuedCompletionStatus returned inva
lid mode=%d\n", mode); |
104 runtime·throw("netpoll: GetQueuedCompletionStatus returned inval
id mode"); | 104 runtime·throw("netpoll: GetQueuedCompletionStatus returned inval
id mode"); |
105 } | 105 } |
106 o->errno = errno; | 106 o->errno = errno; |
107 o->qty = qty; | 107 o->qty = qty; |
108 runtime·netpollready(&gp, (void*)o->runtimeCtx, mode); | 108 runtime·netpollready(&gp, (void*)o->runtimeCtx, mode); |
109 if(block && gp == nil) | 109 if(block && gp == nil) |
110 goto retry; | 110 goto retry; |
111 return gp; | 111 return gp; |
112 } | 112 } |
LEFT | RIGHT |