renet 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc3737971e23b29665d821c54b1dc8a21df161a8
4
- data.tar.gz: 695578b48b98cd09a6d3ba636f4e87f0485bab29
3
+ metadata.gz: f332d6f6ddc4ab88a3040a50807e1bab8244e2e0
4
+ data.tar.gz: d05c0480678a493730ac76734c72c7bc4e01dbea
5
5
  SHA512:
6
- metadata.gz: d1aee7548aa76a3b622841acbc3a7107a75ce6e5f969f5c5b541f9bd09a33ee8ff97d833c51dee7de918ee18263e50dcbe381761bb69847a3746837e2093cb93
7
- data.tar.gz: 7e15e9b139aad404af1d79f32f5ec240c8eeb3c0347db7363183e2b5e804212d51c054658eca38c4439acb63b2e8b70af168f7489eece6585bf145212b257b7d
6
+ metadata.gz: b54950e6c229e46b00ef6e87b7e41b48cd0c87011c88df24ade3d4962db1ef6aeac7bf73a931f32dacd3cff6dfcb91bffe4ec23864b3e5de08a52657911ff01c
7
+ data.tar.gz: 8e51547c005807b50e85bad9bf60dead316ffc68015119966a417c614e5b0b979a8856a8cee314192ce626d3afd305983d6e2a02fbde8f0f94745cb55ae5d5d9
@@ -17,6 +17,7 @@
17
17
  */
18
18
 
19
19
  #include "renet_connection.h"
20
+ #include <ruby.h>
20
21
 
21
22
  void init_renet_connection()
22
23
  {
@@ -110,31 +111,25 @@ typedef struct
110
111
  {
111
112
  Connection * connection;
112
113
  enet_uint32 timeout;
114
+ int result;
113
115
  } CallbackData;
114
116
 
115
- static VALUE do_service(void *data)
117
+ static void* do_service(void *data)
116
118
  {
117
119
  CallbackData* temp_data = data;
118
- int result = enet_host_service(temp_data->connection->host, temp_data->connection->event, temp_data->timeout);
119
- // this will do weird things with the negative numbers but we'll undo it on the other side
120
- return (unsigned int)result;
120
+ temp_data->result = enet_host_service(temp_data->connection->host, temp_data->connection->event, temp_data->timeout);
121
+ return NULL;
121
122
  }
122
123
 
123
124
  static int service(VALUE self, Connection* connection, enet_uint32 timeout)
124
125
  {
125
- CallbackData data = {connection, timeout};
126
- VALUE result;
126
+ CallbackData data = {connection, timeout, -1};
127
127
  if (timeout > 0)
128
- {
129
- result = rb_thread_blocking_region(do_service, &data, RUBY_UBF_IO, 0);
130
- }
128
+ { rb_thread_call_without_gvl(do_service, &data, RUBY_UBF_IO, NULL); }
131
129
  else
132
- {
133
- result = do_service(&data);
134
- }
135
- // undo our cast to VALUE in a way that will properly restore negative numbers
136
- unsigned int fix_negatives = (unsigned int)result;
137
- return (int)fix_negatives;
130
+ { do_service(&data); }
131
+
132
+ return data.result;
138
133
  }
139
134
 
140
135
 
@@ -17,7 +17,7 @@
17
17
  */
18
18
 
19
19
  #include "renet_server.h"
20
-
20
+ #include <ruby.h>
21
21
 
22
22
  void init_renet_server()
23
23
  {
@@ -170,31 +170,26 @@ typedef struct
170
170
  {
171
171
  Server * server;
172
172
  enet_uint32 timeout;
173
+ int result;
173
174
  } CallbackData;
174
175
 
175
- static VALUE do_service(void *data)
176
+ static void* do_service(void *data)
176
177
  {
177
178
  CallbackData* temp_data = data;
178
- int result = enet_host_service(temp_data->server->host, temp_data->server->event, temp_data->timeout);
179
- // this will do weird things with the negative numbers but we'll undo it on the other side
180
- return (unsigned int)result;
179
+ temp_data->result = enet_host_service(temp_data->server->host, temp_data->server->event, temp_data->timeout);
180
+ return NULL;
181
181
  }
182
182
 
183
183
  static int service(VALUE self, Server* server, enet_uint32 timeout)
184
184
  {
185
- CallbackData data = {server, timeout};
186
- VALUE result;
185
+ CallbackData data = {server, timeout, -1};
186
+
187
187
  if (timeout > 0)
188
- {
189
- result = rb_thread_blocking_region(do_service, &data, RUBY_UBF_IO, 0);
190
- }
188
+ { rb_thread_call_without_gvl(do_service, &data, RUBY_UBF_IO, NULL); }
191
189
  else
192
- {
193
- result = do_service(&data);
194
- }
195
- // undo our cast to VALUE in a way that will properly restore negative numbers
196
- unsigned int fix_negatives = (unsigned int)result;
197
- return (int)fix_negatives;
190
+ { do_service(&data); }
191
+
192
+ return data.result;
198
193
  }
199
194
 
200
195
  VALUE renet_server_update(VALUE self, VALUE timeout)
@@ -5,6 +5,7 @@
5
5
  #ifdef _WIN32
6
6
 
7
7
  #define ENET_BUILDING_LIB 1
8
+ #define INCL_WINSOCK_API_TYPEDEFS 1
8
9
  #include "enet/enet.h"
9
10
  #include <windows.h>
10
11
  #include <mmsystem.h>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dahrkael & Job Vranish
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-12 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby library for games networking. Uses ENet as backend
14
14
  email: dark.wolf.warrior@gmail.com