nio4r 1.2.1 → 2.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/workflow.yml +43 -0
  3. data/.gitignore +1 -0
  4. data/.rspec +0 -1
  5. data/.rubocop.yml +70 -31
  6. data/CHANGES.md +190 -42
  7. data/Gemfile +8 -4
  8. data/Guardfile +10 -0
  9. data/README.md +102 -147
  10. data/Rakefile +3 -4
  11. data/examples/echo_server.rb +3 -2
  12. data/ext/libev/Changes +44 -13
  13. data/ext/libev/README +2 -1
  14. data/ext/libev/ev.c +314 -225
  15. data/ext/libev/ev.h +90 -88
  16. data/ext/libev/ev_epoll.c +30 -16
  17. data/ext/libev/ev_kqueue.c +19 -9
  18. data/ext/libev/ev_linuxaio.c +642 -0
  19. data/ext/libev/ev_poll.c +19 -11
  20. data/ext/libev/ev_port.c +13 -6
  21. data/ext/libev/ev_select.c +4 -2
  22. data/ext/libev/ev_vars.h +14 -3
  23. data/ext/libev/ev_wrap.h +16 -0
  24. data/ext/nio4r/bytebuffer.c +429 -0
  25. data/ext/nio4r/extconf.rb +17 -30
  26. data/ext/nio4r/monitor.c +113 -49
  27. data/ext/nio4r/nio4r.h +11 -13
  28. data/ext/nio4r/org/nio4r/ByteBuffer.java +293 -0
  29. data/ext/nio4r/org/nio4r/Monitor.java +175 -0
  30. data/ext/nio4r/org/nio4r/Nio4r.java +22 -391
  31. data/ext/nio4r/org/nio4r/Selector.java +299 -0
  32. data/ext/nio4r/selector.c +155 -68
  33. data/lib/nio.rb +4 -4
  34. data/lib/nio/bytebuffer.rb +229 -0
  35. data/lib/nio/monitor.rb +73 -11
  36. data/lib/nio/selector.rb +64 -21
  37. data/lib/nio/version.rb +1 -1
  38. data/nio4r.gemspec +34 -20
  39. data/{tasks → rakelib}/extension.rake +4 -0
  40. data/{tasks → rakelib}/rspec.rake +2 -0
  41. data/{tasks → rakelib}/rubocop.rake +2 -0
  42. data/spec/nio/acceptables_spec.rb +5 -5
  43. data/spec/nio/bytebuffer_spec.rb +354 -0
  44. data/spec/nio/monitor_spec.rb +128 -79
  45. data/spec/nio/selectables/pipe_spec.rb +12 -3
  46. data/spec/nio/selectables/ssl_socket_spec.rb +61 -29
  47. data/spec/nio/selectables/tcp_socket_spec.rb +47 -34
  48. data/spec/nio/selectables/udp_socket_spec.rb +24 -7
  49. data/spec/nio/selector_spec.rb +65 -16
  50. data/spec/spec_helper.rb +12 -3
  51. data/spec/support/selectable_examples.rb +45 -18
  52. metadata +33 -23
  53. data/.rubocop_todo.yml +0 -35
  54. data/.travis.yml +0 -27
  55. data/LICENSE.txt +0 -20
  56. data/ext/libev/README.embed +0 -3
  57. data/ext/libev/test_libev_win32.c +0 -123
@@ -1,35 +0,0 @@
1
- # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2015-04-24 03:08:21 -0700 using RuboCop version 0.30.1.
3
- # The point is for the user to remove these configuration records
4
- # one by one as the offenses are removed from the code base.
5
- # Note that changes in the inspected code, or installation of new
6
- # versions of RuboCop, may require this file to be generated again.
7
-
8
- # Offense count: 2
9
- Lint/HandleExceptions:
10
- Enabled: false
11
-
12
- # Offense count: 3
13
- Lint/Loop:
14
- Enabled: false
15
-
16
- # Offense count: 1
17
- Lint/NonLocalExitFromIterator:
18
- Enabled: false
19
-
20
- # Offense count: 7
21
- Lint/UselessAssignment:
22
- Enabled: false
23
-
24
- # Offense count: 1
25
- # Configuration parameters: SupportedStyles, IndentOneStep.
26
- Style/CaseIndentation:
27
- IndentWhenRelativeTo: end
28
-
29
- # Offense count: 1
30
- Style/Documentation:
31
- Enabled: false
32
-
33
- # Offense count: 2
34
- Style/RescueModifier:
35
- Enabled: false
@@ -1,27 +0,0 @@
1
- language: ruby
2
- sudo: false
3
-
4
- rvm:
5
- - 2.0.0
6
- - 2.1.1
7
- - 2.2.2
8
- - ruby-head
9
- - jruby
10
- - jruby-head
11
- - rbx-2
12
-
13
- env:
14
- - NIO4R_PURE=false
15
- - NIO4R_PURE=true
16
-
17
- matrix:
18
- fast_finish: true
19
- allow_failures:
20
- - rvm: ruby-head
21
- - rvm: jruby-head
22
- - rvm: rbx-2
23
- - rvm: jruby
24
- env: NIO4R_PURE=true
25
-
26
- notifications:
27
- irc: "irc.freenode.org#celluloid"
@@ -1,20 +0,0 @@
1
- Copyright (c) 2011-12 Tony Arcieri
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,3 +0,0 @@
1
- This file is now included in the main libev documentation, see
2
-
3
- http://cvs.schmorp.de/libev/ev.html
@@ -1,123 +0,0 @@
1
- // a single header file is required
2
- #include <ev.h>
3
- #include <stdio.h>
4
- #include <io.h>
5
-
6
- // every watcher type has its own typedef'd struct
7
- // with the name ev_TYPE
8
- ev_io stdin_watcher;
9
- ev_timer timeout_watcher;
10
-
11
- // all watcher callbacks have a similar signature
12
- // this callback is called when data is readable on stdin
13
- static void
14
- stdin_cb (EV_P_ ev_io *w, int revents)
15
- {
16
- puts ("stdin ready or done or something");
17
- // for one-shot events, one must manually stop the watcher
18
- // with its corresponding stop function.
19
- //ev_io_stop (EV_A_ w);
20
-
21
- // this causes all nested ev_loop's to stop iterating
22
- //ev_unloop (EV_A_ EVUNLOOP_ALL);
23
- }
24
-
25
- // another callback, this time for a time-out
26
- static void
27
- timeout_cb (EV_P_ ev_timer *w, int revents)
28
- {
29
- puts ("timeout");
30
- // this causes the innermost ev_loop to stop iterating
31
- ev_unloop (EV_A_ EVUNLOOP_ONE);
32
- }
33
-
34
-
35
-
36
- #include <winsock.h>
37
-
38
- #include <stdlib.h>
39
- #include <iostream>
40
- int get_server_fd()
41
- {
42
-
43
- //----------------------
44
- // Initialize Winsock.
45
- WSADATA wsaData;
46
- int iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
47
- if (iResult != NO_ERROR) {
48
- printf("Error at WSAStartup()\n");
49
- return 1;
50
- }
51
-
52
- //----------------------
53
- // Create a SOCKET for listening for
54
- // incoming connection requests.
55
- SOCKET ListenSocket;
56
- ListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
57
- if (ListenSocket == INVALID_SOCKET) {
58
- printf("Error at socket(): %ld\n", WSAGetLastError());
59
- WSACleanup();
60
- return 1;
61
- }
62
- printf("socket returned %d\n", ListenSocket);
63
-
64
- //----------------------
65
- // The sockaddr_in structure specifies the address family,
66
- // IP address, and port for the socket that is being bound.
67
- sockaddr_in service;
68
- service.sin_family = AF_INET;
69
- service.sin_addr.s_addr = inet_addr("127.0.0.1");
70
- service.sin_port = htons(4444);
71
-
72
- if (bind( ListenSocket,
73
- (SOCKADDR*) &service,
74
- sizeof(service)) == SOCKET_ERROR) {
75
- printf("bind() failed.\n");
76
- closesocket(ListenSocket);
77
- WSACleanup();
78
- return 1;
79
- }
80
-
81
- //----------------------
82
- // Listen for incoming connection requests.
83
- // on the created socket
84
- if (listen( ListenSocket, 1 ) == SOCKET_ERROR) {
85
- printf("Error listening on socket.\n");
86
- closesocket(ListenSocket);
87
- WSACleanup();
88
- return 1;
89
- }
90
-
91
-
92
- printf("sock and osf handle are %d %d, error is \n", ListenSocket, _get_osfhandle (ListenSocket)); // -1 is invalid file handle: http://msdn.microsoft.com/en-us/library/ks2530z6.aspx
93
- printf("err was %d\n", WSAGetLastError());
94
- //----------------------
95
- return ListenSocket;
96
- }
97
-
98
-
99
- int
100
- main (void)
101
- {
102
- struct ev_loop *loopy = ev_default_loop(0);
103
- int fd = get_server_fd();
104
- int fd_real = _open_osfhandle(fd, NULL);
105
- int conv = _get_osfhandle(fd_real);
106
- printf("got server fd %d, loop %d, fd_real %d, that converted %d\n", fd, loopy, fd_real, conv);
107
- // accept(fd, NULL, NULL);
108
- // initialise an io watcher, then start it
109
- // this one will watch for stdin to become readable
110
- ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ conv, EV_READ);
111
- ev_io_start (loopy, &stdin_watcher);
112
-
113
- // initialise a timer watcher, then start it
114
- // simple non-repeating 5.5 second timeout
115
- //ev_timer_init (&timeout_watcher, timeout_cb, 15.5, 0.);
116
- //ev_timer_start (loopy, &timeout_watcher);
117
- printf("starting loop\n");
118
- // now wait for events to arrive
119
- ev_loop (loopy, 0);
120
-
121
- // unloop was called, so exit
122
- return 0;
123
- }