Commit Graph

31 Commits

Author SHA1 Message Date
John Nunley 5b74dc8acc
Merge fetch_and andthe prev_value check
cc https://github.com/smol-rs/concurrent-queue/pull/58#discussion_r1574686897

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-25 22:53:55 -07:00
James Liu 89a64f8c3b
feat: Make unbounded a const function
This PR makes `ConcurrentQueue::unbounded` a const function. It'd be great if `bounded` could be `const` as well, but this would likely require static memory allocation support in const functions, which is currently not allowed by the compiler. This would enable https://github.com/smol-rs/async-executor/pull/112 to be directly constructable in a const context (i.e. static/thread_local variable initialization without OnceLock). It might also allow unbounded `async_channel`s to be constructed in a similar context.

Co-authored-by: Taiki Endo <te316e89@gmail.com>
2024-04-13 09:01:26 -07:00
John Nunley 59e93fc952
ci: Test loom under no-default-features
This commit adds loom tests to CI with --no-default-features, then also
fixes a compile error that was introduced in a new version of loom.

Closes #64
2024-03-31 11:09:52 -07:00
John Nunley c407467c20
feat: Add an overflow push method
In some cases it is desired to have a "lossy" queue for data. Such as an
event queue where more recent events should be prioritized over older
ones, where infinite storage is impractical. This commit adds a method
called "force_push" which enables this usage.

Bounded queue code is partially derived from the following commit:
bd75c3c45e

cc smol-rs/async-channel#44
2024-03-30 16:38:05 -07:00
Taiki Endo d49453323c Remove dead code
```
error: method `with` is never used
  --> src/sync.rs:65:12
   |
62 |     pub(crate) trait UnsafeCellExt {
   |                      ------------- method in this trait
...
65 |         fn with<R, F>(&self, f: F) -> R
   |            ^^^^
   |
   = note: `-D dead-code` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(dead_code)]`
```
2024-03-06 02:19:43 +09:00
Irine c0e1098aa0
bugfix: Remove the heap allocation from non-single queues 2023-11-15 18:08:17 -08:00
MrEconomical 04f3a1eecc
feat: Implement UnwindSafe on core (#49) 2023-08-25 21:15:31 +09:00
Taiki Endo cbdf9e88e1
bugfix: Use inline assembly in full_fence
This commit bumps the MSRV to 1.59
2023-08-13 14:33:40 -07:00
John Nunley b660d795a4
Add smol-rs logo (#45) 2023-07-17 14:33:21 +09:00
John Nunley f877490dcb
feat: Add the try_iter method (#36) 2023-03-06 19:22:48 -08:00
Taiki Endo b5463b2f5e Update portable-atomic to 1.0 2023-01-15 23:14:59 +09:00
Taiki Endo 6be67b375d Fix clippy::bool_to_int_with_if warning
```
warning: boolean to int conversion using if
  --> src/single.rs:93:9
   |
93 | /         if self.state.load(Ordering::SeqCst) & PUSHED == 0 {
94 | |             0
95 | |         } else {
96 | |             1
97 | |         }
   | |_________^ help: replace with from: `usize::from(self.state.load(Ordering::SeqCst) & PUSHED != 0)`
   |
   = note: `(self.state.load(Ordering::SeqCst) & PUSHED != 0) as usize` or `(self.state.load(Ordering::SeqCst) & PUSHED != 0).into()` can also be valid options
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_to_int_with_if
   = note: `#[warn(clippy::bool_to_int_with_if)]` on by default
```
2022-12-16 21:08:10 +09:00
John Nunley 8c42b8dd9d
Add alternate implementations of synchronization primitives (#27) 2022-10-07 06:48:10 -07:00
John Nunley 06c99537c2
replace cache_padded with crossbeam-utils (#26) 2022-09-06 09:22:39 -07:00
John Nunley d3bf5a5424
Make it so this crate can be `no_std` (#22) 2022-08-25 02:09:13 +09:00
Taiki Endo 9de877f9e0 Do not copy data before dropping 2022-07-22 00:03:27 +09:00
Taiki Endo d1218a02e0 Use get_mut instead of atomic load in Drop impls 2022-07-22 00:03:27 +09:00
Taiki Endo d61005fc79 Do not use x86 specific fence on Miri 2022-07-20 23:18:24 +09:00
Taiki Endo bc4f426618 Use compiler_fence in full_fence on x86 2022-07-20 23:18:24 +09:00
Taiki Endo 194cf156b1 Revert "Fix fence on non-x86 arch and miri (#16)"
This reverts commit 54df36a543.
2022-07-20 23:18:24 +09:00
Taiki Endo 54df36a543
Fix fence on non-x86 arch and miri (#16) 2022-07-17 22:33:35 +09:00
Taiki Endo cefe5efc42 Replace deprecated compare_and_swap with compare_exchange 2020-12-24 21:28:40 +09:00
Stjepan Glavina ee83323156 Add special bounded(1) implementation 2020-08-05 18:57:58 +02:00
Stjepan Glavina 83223b50a5 Remove PhantomData 2020-08-05 17:25:08 +02:00
Stjepan Glavina 0eab7ff973 Use a boxed slice instead of raw pointers 2020-08-04 19:02:03 +02:00
Stjepan Glavina c680f8d84f Implement UnwindSafe/RefUnwindSafe 2020-07-31 14:26:39 +02:00
Stjepan Glavina e4a9db66f4 Optimize SeqCst fences 2020-07-22 17:57:03 +02:00
Greg Fitzgerald dc97271091 Remove redundant conditional 2020-07-21 15:36:58 -06:00
Stjepan Glavina 5ee969c26f Clarify errors in docs 2020-06-02 16:45:41 +02:00
Stjepan Glavina 8a04fb97ba Add extra methods to error types 2020-06-02 16:40:42 +02:00
Stjepan Glavina 463ae0ea93 Initial commit 2020-05-27 21:31:05 +02:00