min_max 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: 80798043e91a2c00c6bda06b9cee1fe9544d9eb57c38d2d1ef41c4147614ff80
4
- data.tar.gz: 7394b9168a389e57917780169a0a2574ea5982a4a373c67c36770bc893dfae75
3
+ metadata.gz: aef5e878c1412daa7a16bf7aad72afff1bdcc4cfa37709e6a88601d6ef2f1a93
4
+ data.tar.gz: 74f22abb3ad7a47e654cf6033d0512e00344a373e21aa18e46f86a9d38e6dc17
5
5
  SHA512:
6
- metadata.gz: 5c746c1cbdba8f6e5e752949145bd2604eefa14b75a5c5cb6b6b1a0c81eaaa75538451438cc001769336cbdf9d2e118a2c2c9a397b3d6ea00ce70f37227de576
7
- data.tar.gz: 172aa5d4652493bcfbcd92bbad0ffbd06c72910c63ddf7c59e665ed017d300ba453d18953983c44e95fb5362e4c37ebfad5d79c4167e3736deed47ebc32e0f74
6
+ metadata.gz: 0b992bc50cd6e4920503b8a9257916dc3cb83326126c9e56c38fb693bbf513335573f8c7730386109044de48f58dd6e8a9c1da7f4a6e91e9f28e2aeb981cd23c
7
+ data.tar.gz: e5f84db084190697f2d8ab7738b70fc82ae2b4a23466936d47e74aef27e46dd39f1f2e5885b1a7d3f876f28aadc0dfc747dabffe36c05eaa3f4661f7424091bf
data/Cargo.lock CHANGED
@@ -13,16 +13,16 @@ dependencies = [
13
13
 
14
14
  [[package]]
15
15
  name = "bindgen"
16
- version = "0.66.1"
16
+ version = "0.69.4"
17
17
  source = "registry+https://github.com/rust-lang/crates.io-index"
18
- checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
18
+ checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
19
19
  dependencies = [
20
20
  "bitflags",
21
21
  "cexpr",
22
22
  "clang-sys",
23
+ "itertools",
23
24
  "lazy_static",
24
25
  "lazycell",
25
- "peeking_take_while",
26
26
  "proc-macro2",
27
27
  "quote",
28
28
  "regex",
@@ -63,12 +63,27 @@ dependencies = [
63
63
  "libloading",
64
64
  ]
65
65
 
66
+ [[package]]
67
+ name = "either"
68
+ version = "1.10.0"
69
+ source = "registry+https://github.com/rust-lang/crates.io-index"
70
+ checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a"
71
+
66
72
  [[package]]
67
73
  name = "glob"
68
74
  version = "0.3.1"
69
75
  source = "registry+https://github.com/rust-lang/crates.io-index"
70
76
  checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
71
77
 
78
+ [[package]]
79
+ name = "itertools"
80
+ version = "0.12.1"
81
+ source = "registry+https://github.com/rust-lang/crates.io-index"
82
+ checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
83
+ dependencies = [
84
+ "either",
85
+ ]
86
+
72
87
  [[package]]
73
88
  name = "lazy_static"
74
89
  version = "1.4.0"
@@ -139,6 +154,7 @@ dependencies = [
139
154
  "lazy_static",
140
155
  "magnus",
141
156
  "min-max-heap",
157
+ "rb-sys",
142
158
  ]
143
159
 
144
160
  [[package]]
@@ -157,12 +173,6 @@ dependencies = [
157
173
  "minimal-lexical",
158
174
  ]
159
175
 
160
- [[package]]
161
- name = "peeking_take_while"
162
- version = "0.1.2"
163
- source = "registry+https://github.com/rust-lang/crates.io-index"
164
- checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
165
-
166
176
  [[package]]
167
177
  name = "proc-macro2"
168
178
  version = "1.0.66"
@@ -183,18 +193,18 @@ dependencies = [
183
193
 
184
194
  [[package]]
185
195
  name = "rb-sys"
186
- version = "0.9.81"
196
+ version = "0.9.89"
187
197
  source = "registry+https://github.com/rust-lang/crates.io-index"
188
- checksum = "a57240b308b155b09dce81e32829966a99f52d1088b45957e4283e526c5317a1"
198
+ checksum = "0d197f2c03751ef006f29d593d22aa9068c9c358e04ca503afea0329c366147c"
189
199
  dependencies = [
190
200
  "rb-sys-build",
191
201
  ]
192
202
 
193
203
  [[package]]
194
204
  name = "rb-sys-build"
195
- version = "0.9.81"
205
+ version = "0.9.89"
196
206
  source = "registry+https://github.com/rust-lang/crates.io-index"
197
- checksum = "f24ce877a4c5d07f06f6aa6fec3ac95e4b357b9f73b0f5445d8cbb7266d410e8"
207
+ checksum = "2b50caf8fd028f12abe00d6debe2ae2adf6202c9ca3caa59487eda710d90fa28"
198
208
  dependencies = [
199
209
  "bindgen",
200
210
  "lazy_static",
@@ -10,6 +10,7 @@ publish = false
10
10
  crate-type = ["cdylib"]
11
11
 
12
12
  [dependencies]
13
- magnus = { version = "0.6.1" }
13
+ magnus = { version = "0.6.1"}
14
14
  min-max-heap = "1.3.0"
15
15
  lazy_static = "1.4.0"
16
+ rb-sys = { version = "0.9.89", features=["stable-api-compiled-fallback"]}
@@ -1,13 +1,13 @@
1
1
  use magnus::block::Proc;
2
2
  use magnus::scan_args::scan_args;
3
- use magnus::value::{BoxValue, ReprValue};
3
+ use magnus::value::ReprValue;
4
4
  use magnus::{
5
5
  block::{block_given, Yield},
6
6
  define_class, function, method,
7
7
  prelude::*,
8
8
  Error, IntoValue, RArray, Ruby, Value,
9
9
  };
10
- use magnus::{eval, DataTypeFunctions, RHash, RString, TypedData};
10
+ use magnus::{eval, gc, DataTypeFunctions, RHash, RString, TypedData};
11
11
  use min_max_heap::MinMaxHeap;
12
12
  use std::cell::RefCell;
13
13
  use std::collections::HashMap;
@@ -20,7 +20,7 @@ struct PriorityOrderableValue(i64, i64);
20
20
  extern crate lazy_static;
21
21
 
22
22
  struct MEM(
23
- RwLock<HashMap<i64, BoxValue<Value>>>,
23
+ RwLock<HashMap<i64, Box<Value>>>,
24
24
  RwLock<HashMap<i64, RefCell<usize>>>,
25
25
  );
26
26
 
@@ -51,6 +51,7 @@ fn pop_rb_obj(key: i64) -> Option<Value> {
51
51
  *count -= 1;
52
52
  let res = if *count == 0 {
53
53
  let val = (*MEMORY).0.write().unwrap().remove(&key).unwrap();
54
+ gc::unregister_address(&*val);
54
55
  Some(*val)
55
56
  } else {
56
57
  let binding = (*MEMORY).0.read().unwrap();
@@ -66,11 +67,9 @@ fn push_rb_obj(key: i64, value: Value) -> i64 {
66
67
 
67
68
  *count += 1;
68
69
  if *count == 1 {
69
- (*MEMORY)
70
- .0
71
- .write()
72
- .unwrap()
73
- .insert(key, BoxValue::new(value));
70
+ let boxed = Box::new(value);
71
+ gc::register_address(&*boxed);
72
+ (*MEMORY).0.write().unwrap().insert(key, boxed);
74
73
  };
75
74
  return key;
76
75
  }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class MinMax
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
 
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: min_max
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters