Browse Source

Merge pull request #9 from bspeice/deprecation

Mark everything deprecated
bspeice 3 months ago
parent
commit
963d634923
No account linked to committer's email address
6 changed files with 72 additions and 8 deletions
  1. 7
    1
      CHANGELOG.md
  2. 29
    5
      README.md
  3. 2
    2
      qadapt-macro/Cargo.toml
  4. 2
    0
      qadapt-macro/README.md
  5. 6
    0
      qadapt-macro/src/lib.rs
  6. 26
    0
      src/lib.rs

+ 7
- 1
CHANGELOG.md View File

@@ -1,4 +1,10 @@
1
-# Version 1.1.0
1
+# Version 1.0.3
2
+
3
+- Mark the crate deprecated; [alloc-counter](https://crates.io/crates/alloc_counter)
4
+  does a better job at solving the problems QADAPT was driven for, and I'll be putting
5
+  my effort towards improving it instead.
6
+
7
+# Version 1.0.2
2 8
 
3 9
 - Don't panic if calling guarded code and QADAPT isn't the allocator;
4 10
   Instead, let code determine at runtime whether or not QADAPT is enabled

+ 29
- 5
README.md View File

@@ -9,6 +9,8 @@
9 9
 ---
10 10
 ## `debug_assert!` for your memory usage
11 11
 
12
+**Please note**: This crate has been deprecated in favor of [alloc-counter](https://crates.io/crates/alloc_counter).
13
+
12 14
 This allocator is a helper for writing high-performance code that is memory-sensitive;
13 15
 a thread panic will be triggered if a function annotated with `#[no_alloc]`,
14 16
 or code inside an `assert_no_alloc!` macro interacts with the allocator in any way.
@@ -26,18 +28,31 @@ circumstance causing your application to crash.
26 28
 Actually making use of QADAPT is straight-forward. To set up the allocator,
27 29
 place the following snippet in either your program binaries (main.rs) or tests:
28 30
 
29
-```rust,ignore
31
+```rust
30 32
 use qadapt::QADAPT;
31 33
 
32 34
 #[global_allocator]
33 35
 static Q: QADAPT = QADAPT;
36
+
37
+fn main() {
38
+    # // Because `debug_assertions` are on for doctests in release mode
39
+    # // we have to add an extra guard.
40
+    # if qadapt::is_active() {
41
+    assert!(qadapt::is_active());
42
+    # }
43
+}
34 44
 ```
35 45
 
36 46
 After that, there are two ways of telling QADAPT that it should trigger a panic:
37 47
 
38 48
 1. Annotate functions with the `#[no_alloc]` proc macro:
39
-```rust,no_run
49
+```rust
40 50
 use qadapt::no_alloc;
51
+use qadapt::QADAPT;
52
+use std::panic::catch_unwind;
53
+
54
+#[global_allocator]
55
+static Q: QADAPT = QADAPT;
41 56
 
42 57
 // This function is fine, there are no allocations here
43 58
 #[no_alloc]
@@ -53,15 +68,23 @@ fn does_panic() -> Box<u32> {
53 68
 
54 69
 fn main() {
55 70
     do_math();
56
-    does_panic();
71
+
72
+    let err = catch_unwind(|| does_panic());
73
+    # if qadapt::is_active() {
74
+    assert!(err.is_err());
75
+    # }
57 76
 }
58 77
 ```
59 78
 
60 79
 2. Evaluate expressions with the `assert_no_alloc!` macro
61
-```rust,no_run
80
+```rust
62 81
 use qadapt::assert_no_alloc;
82
+use qadapt::QADAPT;
63 83
 
64
-fn do_work() {
84
+#[global_allocator]
85
+static Q: QADAPT = QADAPT;
86
+
87
+fn main() {
65 88
     // This code is allowed to trigger an allocation
66 89
     let b = Box::new(8);
67 90
     
@@ -69,3 +92,4 @@ fn do_work() {
69 92
     let x = assert_no_alloc!(*b + 2);
70 93
     assert_eq!(x, 10);
71 94
 }
95
+```

+ 2
- 2
qadapt-macro/Cargo.toml View File

@@ -1,6 +1,6 @@
1 1
 [package]
2 2
 name = "qadapt-macro"
3
-version = "1.0.2"
3
+version = "1.0.3"
4 4
 authors = ["Bradlee Speice <bradlee@speice.io>"]
5 5
 description = "The Quick And Dirty Allocation Profiling Tool - Support Macros"
6 6
 license = "Apache-2.0"
@@ -16,7 +16,7 @@ repository = "https://github.com/bspeice/qadapt.git"
16 16
 edition = "2018"
17 17
 
18 18
 [badges]
19
-maintenance = { status = "actively-developed" }
19
+maintenance = { status = "deprecated" }
20 20
 
21 21
 [lib]
22 22
 proc-macro = true

+ 2
- 0
qadapt-macro/README.md View File

@@ -5,5 +5,7 @@
5 5
 
6 6
 Helper macro for the QADAPT allocator.
7 7
 
8
+**Please note**: This crate has been deprecated in favor of [alloc-counter](https://crates.io/crates/alloc_counter)
9
+
8 10
 This crate is intended for managing the QADAPT allocator,
9 11
 and is unusable on its own.

+ 6
- 0
qadapt-macro/src/lib.rs View File

@@ -1,5 +1,7 @@
1 1
 //! Helper macros to use with the QADAPT allocator system
2 2
 //!
3
+//! **Please note**: This crate has been deprecated in favor of [alloc-counter](https://crates.io/crates/alloc_counter)
4
+//!
3 5
 //! This crate is intended for managing the QADAPT allocator,
4 6
 //! and is unusable on its own.
5 7
 //!
@@ -155,6 +157,10 @@ fn escape_return(ts: TokenStream) -> TokenStream {
155 157
 /// separate thread, or defers allocations via closure/Future, those results
156 158
 /// will not trigger an error.
157 159
 #[proc_macro_attribute]
160
+#[deprecated(
161
+    since = "1.0.3",
162
+    note = "Please use the `alloc_counter` crate instead."
163
+)]
158 164
 pub fn no_alloc(_attr: TokenStream, item: TokenStream) -> TokenStream {
159 165
     let mut protected_fn: Vec<TokenTree> = Vec::new();
160 166
     let mut item_iter = item.into_iter();

+ 26
- 0
src/lib.rs View File

@@ -1,5 +1,7 @@
1 1
 //! ## `debug_assert!` for your memory usage
2 2
 //!
3
+//! **Please note**: This crate has been deprecated in favor of [alloc-counter](https://crates.io/crates/alloc_counter).
4
+//!
3 5
 //! This allocator is a helper for writing high-performance code that is memory-sensitive;
4 6
 //! a thread panic will be triggered if a function annotated with `#[no_alloc]`,
5 7
 //! or code inside an `assert_no_alloc!` macro interacts with the allocator in any way.
@@ -120,6 +122,10 @@ static INTERNAL_ALLOCATION: RwLock<usize> = RwLock::new(usize::max_value());
120 122
 ///     # }
121 123
 /// }
122 124
 /// ```
125
+#[deprecated(
126
+    since = "1.0.3",
127
+    note = "Please use the `alloc_counter` crate instead."
128
+)]
123 129
 pub struct QADAPT;
124 130
 
125 131
 static SYSTEM_ALLOC: System = System;
@@ -150,6 +156,10 @@ static SYSTEM_ALLOC: System = System;
150 156
 ///     // It's now safe to allocate/drop again
151 157
 ///     let z = Box::new(y);
152 158
 /// }
159
+#[deprecated(
160
+    since = "1.0.3",
161
+    note = "Please use the `alloc_counter` crate instead."
162
+)]
153 163
 pub fn enter_protected() {
154 164
     #[cfg(debug_assertions)]
155 165
     {
@@ -191,6 +201,10 @@ pub fn enter_protected() {
191 201
 ///     // It's now safe to allocate/drop again
192 202
 ///     let z = Box::new(y);
193 203
 /// }
204
+#[deprecated(
205
+    since = "1.0.3",
206
+    note = "Please use the `alloc_counter` crate instead."
207
+)]
194 208
 pub fn exit_protected() {
195 209
     #[cfg(debug_assertions)]
196 210
     {
@@ -259,6 +273,10 @@ pub fn exit_protected() {
259 273
 ///     # }
260 274
 /// }
261 275
 #[macro_export]
276
+#[deprecated(
277
+    since = "1.0.3",
278
+    note = "Please use the `alloc_counter` crate instead."
279
+)]
262 280
 macro_rules! assert_no_alloc {
263 281
     ($e:expr) => {{
264 282
         ::qadapt::enter_protected();
@@ -298,6 +316,10 @@ macro_rules! assert_no_alloc {
298 316
 ///     
299 317
 ///     // It's now safe to allocate/drop
300 318
 /// }
319
+#[deprecated(
320
+    since = "1.0.3",
321
+    note = "Please use the `alloc_counter` crate instead."
322
+)]
301 323
 pub fn protection_level() -> usize {
302 324
     PROTECTION_LEVEL.try_with(|v| *v.read()).unwrap_or(0)
303 325
 }
@@ -324,6 +346,10 @@ pub fn protection_level() -> usize {
324 346
 ///     # }
325 347
 /// }
326 348
 /// ```
349
+#[deprecated(
350
+    since = "1.0.3",
351
+    note = "Please use the `alloc_counter` crate instead."
352
+)]
327 353
 pub fn is_active() -> bool {
328 354
     if cfg!(debug_assertions) {
329 355
         // Because there are heap allocations that happen before `fn main()`,

Loading…
Cancel
Save