Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 51 lines (42 sloc) 2.059 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 type supported_event = In | Out | Err
19
20 (* external fct : unit -> int = "fct" *)
21 let dummy_fun1 _ = assert false
22 let dummy_fun2 _ _ = assert false
23 let dummy_fun3 _ _ _ = assert false
24
25 #<Ifstatic:MLSTATE_WINDOWS .*>
26 external socket : unit -> Unix.file_descr = "iocp_ml_socket"
27 external iocp_async_wait : int -> Unix.file_descr * int = "iocp_ml_wait"
28 external async_accept : Unix.file_descr -> Unix.file_descr = "iocp_ml_accept"
29 external async_init : unit -> unit = "iocp_ml_async_init"
30 external async_read : Unix.file_descr -> int -> Unix.file_descr = "iocp_ml_read"
31 external async_write : Unix.file_descr -> string -> int -> Unix.file_descr = "iocp_ml_write"
32 external get_socket : unit -> Unix.file_descr = "iocp_ml_get_socket"
33 external get_buffer : unit -> string = "iocp_ml_get_buffer"
34
35 let async_wait t =
36 let (fd, int_event) = iocp_async_wait t in
37 let event =
38 if int_event = 0 then In
39 else if int_event = 1 then Out
40 else Err
41 in
42 Printf.printf "new event: %d, %d" (Epoll.Debug.int_of_filedescr fd) int_event;
43 flush stdout;
44 (fd, event)
45
46 #<Else>
47 (* SHOULD BE EMPTY *)
48 let (socket,async_wait,async_accept,async_init,async_read,async_write,get_socket,get_buffer) =
49 (dummy_fun1,dummy_fun1,dummy_fun1,dummy_fun1,dummy_fun2,dummy_fun3,dummy_fun1,dummy_fun1)
50 #<End>
Something went wrong with that request. Please try again.