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 +4 -4
- data/ext/renet/renet_connection.c +10 -15
- data/ext/renet/renet_server.c +11 -16
- data/ext/renet/win32.c +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f332d6f6ddc4ab88a3040a50807e1bab8244e2e0
|
4
|
+
data.tar.gz: d05c0480678a493730ac76734c72c7bc4e01dbea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
117
|
+
static void* do_service(void *data)
|
116
118
|
{
|
117
119
|
CallbackData* temp_data = data;
|
118
|
-
|
119
|
-
|
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
|
-
|
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
|
|
data/ext/renet/renet_server.c
CHANGED
@@ -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
|
176
|
+
static void* do_service(void *data)
|
176
177
|
{
|
177
178
|
CallbackData* temp_data = data;
|
178
|
-
|
179
|
-
|
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
|
-
|
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
|
-
|
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)
|
data/ext/renet/win32.c
CHANGED
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.
|
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-
|
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
|