Commit Graph

214 Commits

Author SHA1 Message Date
John Nunley 23b90f3e8d
tests: Add further testing
Co-authored-by: Jacob Rothstein <hi@jbr.me>
Signed-off-by: John Nunley <dev@notgull.net>
2024-04-18 19:33:29 -07:00
John Nunley 434b390d59
feat: Add a way to get the current number of listeners
Mirror of #114

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-17 21:50:56 -07:00
John Nunley 7bc92d7e83
m: Update fmt::Debug to produce useful output
cc #86, it's harder to get this info on no_std so I've ignored it for
now

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-17 21:50:26 -07:00
John Nunley 99078d12ec
feat: Re-add the is_notified method
cc #48 and #59

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-17 21:48:46 -07:00
Alex Touchet 2dd1fbecdf
Fix build badge and update links (#45) 2024-04-17 21:47:42 -07:00
John Nunley 3430e4517f
docs: Update documentation
- Update Cargo.toml and CHANGELOG.md
- Add back the smol-rs logo (#63)

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-17 21:47:37 -07:00
John Nunley 13399147ff
bench: Add basic benchmarks
Replay of #31 with minor modifications

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-17 17:58:56 -07:00
John Nunley 5511324183
tests: Add a greater breadth of tests
This also makes sure that MIRI can run here.

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-15 20:06:26 -07:00
John Nunley 375e5fdba2
feat: Add back notify() returning the event count
This way added earlier as a way of telling how many listeners were woken
up by a notify() call. It's very simple to implement with the mutex
strategy.

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-15 20:04:57 -07:00
John Nunley 2d62017541
feat: Add back listener! macro
For now it just creates a listener on the heap. We can rework this
later, maybe to include stack listeners. For now it's best to keep it
this way, I feel.

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-15 20:04:43 -07:00
John Nunley c04af898c0
feat: Add back the Listener trait
The Listener trait was previously used to abstract over heap and stack
based event listeners. However at this point we only have heap based
event listeners. Still, to avoid a breaking change we need to have this
trait.

Other minor fixups include:

- Make the locking ignore poisoning.
- Reduce formatting code

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-15 20:04:28 -07:00
John Nunley 5b0b36ae63
feat: Add back portable-atomic feature
This commit adds back a feature that allows one to use portable-atomic
instead of regular atomics.

Kind of useless without no-std, but it's here again.

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-15 20:03:25 -07:00
John Nunley 3d52d2c8ef
feat: Add back tagged events
This commit re-adds the "notify.rs" file pretty much verbatim. This
allows for tagged notifications to be used, i.e. convey additional
control information along with the notification. The tags are stored in
the links with the notification.

This also adds some tests for the new functionality.

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-15 20:02:03 -07:00
John Nunley b3a4ddb3b6
feat: Add back tag generic
This commit adds back the <T> parameter on Event and EventListener. So
far nothing is done with the generic parameter. However it will
eventually be used to bring back tagged events.

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-15 20:01:38 -07:00
Taiki Endo a51a2102a5
chore: Re-apply Taiki's commits
@taiki-e's commits since v2.5.3 aren't the problem, as they only change
CI/framing details. This commit brings back all work by @taiki-e.

Co-authored-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
2024-04-15 20:01:20 -07:00
John Nunley 6368046898
chore: Revert back to v2.5.3
I'm man enough to know when I've been wrong.

The intrusive-list-based list implementation is riddled with bugs, fails
MIRI, and overall increases the complexity of this crate. I've invested
a lot of time and energy into improving it; effort which I feel has been
wasted. So I figure I'll cut my losses and revert.

This PR undoes every commit made between now and the release of
event-listener version 2.5.3. The next commits will be replaying newer
features in order to avoid a breaking change.

Signed-off-by: John Nunley <dev@notgullnet>
2024-04-15 19:58:35 -07:00
John Nunley 2493d3c595 ci: Also add MIRI tests
Signed-off-by: John Nunley <dev@notgull.net>
2024-04-08 14:27:51 -07:00
John Nunley c56420dcf4 ci: Add CI tests for dependent crates
This commit adds tests to CI that tests new patches for event-listener
with dependent crates. Examples of these dependent crates are:

- event-listener-strategy
- async-channel
- async-lock

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-08 14:27:51 -07:00
John Nunley db5857b0b7 v5.3.0
Signed-off-by: John Nunley <dev@notgull.net>
2024-04-05 08:40:07 -07:00
Jacob Rothstein f402b7e24c feat: Add a loom implementation for event-listener 2024-03-30 12:00:55 -07:00
John Nunley 58dbfc8bc5 docs: Make empty listener panic clearer
This commit makes the panic message for a listener that's not inserted
into the linked list much clearer. The goal is to convey to the user
that they may be `poll`ing the listener after it has completed.

This commit also fixes some new Clippy lints.

cc #124

Signed-off-by: John Nunley <dev@notgull.net>
2024-03-28 08:37:08 -07:00
John Nunley 8f11a87281
v5.2.0
Signed-off-by: John Nunley <dev@notgull.net>
2024-02-28 21:15:47 -08:00
John Nunley c9d736a29b
feat: Mark StackSlot as Sync
Since it has no interior mutability it should be safe to share between
threads.

Signed-off-by: John Nunley <dev@notgull.net>
2024-02-25 18:02:44 -08:00
John Nunley 3a49a00639 v5.1.0
Signed-off-by: John Nunley <dev@notgull.net>
2024-02-17 21:37:31 -08:00
Matt Klein e5464b4fdc StackSlot should be send
Signed-off-by: Matt Klein <mklein@bitdrift.io>
2024-02-10 09:53:46 -08:00
Zeeshan Ali Khan ec0c6f9d67
Merge pull request #117 from smol-rs/notgull/next
v5.0.0
2024-02-05 23:10:02 +01:00
John Nunley 4c3568010a
v5.0.0
Signed-off-by: John Nunley <dev@notgull.net>
2024-02-04 19:23:00 -08:00
John Nunley 6e6202b3f1 chore: Polish the implementation of the new API
* Make sure Unpin is implemented for StackListener
* Purge the prelude
* Remove unused imports from doctests

Signed-off-by: John Nunley <dev@notgull.net>
2024-02-03 09:49:22 -08:00
John Nunley 6fc00c0f3f feat: Move Future impl to forwarding macro
Signed-off-by: John Nunley <dev@notgull.net>
2024-02-03 09:49:22 -08:00
John Nunley e0fefc28b1 ex: Remove unsafe code from mutex example
This brings in the try-lock dependency.

Signed-off-by: John Nunley <dev@notgull.net>
2024-02-03 09:49:22 -08:00
John Nunley 68be5281d7 feat: Add stack-based listener
It is instantiated with the listener!() macro.

Signed-off-by: John Nunley <dev@notgull.net>
2024-02-03 09:49:22 -08:00
John Nunley d9144a8a41 feat: Create Listener trait
This commit creates the Listener trait and moves most of EventListener's
functionality to that trait.

Signed-off-by: John Nunley <dev@notgull.net>
2024-02-03 09:49:22 -08:00
John Nunley 86b778074c feat: Move EventListener back onto the heap
Minimal amount of changes to make EventListener a heap-allocated type
again. The existence of the EventListener implies that it is already
listening; accordingly the new() and listen() methods on EventListener
have been removed.

cc #104

Signed-off-by: John Nunley <dev@notgull.net>
2024-02-03 09:49:22 -08:00
John Nunley ac18bdf617
chore: Fix up some minor bits before release
Signed-off-by: John Nunley <dev@notgull.net>
2024-01-27 12:21:00 -08:00
Linken Quy Dinh a68f5ee1b0
feat: Add a way to get the current number of listeners 2024-01-24 20:59:40 -08:00
Taiki Endo 5f5135ed81 Remove RefCell<Option> from PARKER 2024-01-07 22:28:46 +09:00
Taiki Endo b1d437ae83 Release 4.0.3 2024-01-07 03:03:27 +09:00
Taiki Endo aade0393e8 Relax MSRV to 1.60
https://github.com/crossbeam-rs/crossbeam/pull/1056
2024-01-07 02:52:24 +09:00
Taiki Endo 45272f9285 ci: Use cargo-hack's --rust-version flag for msrv check
This respects rust-version field in Cargo.toml, so it removes the need
to manage MSRV in both the CI file and Cargo.toml.
2024-01-07 02:52:24 +09:00
dependabot[bot] 08c7e163a0
Update criterion requirement from 0.4.0 to 0.5.1 (#62)
Updates the requirements on [criterion](https://github.com/bheisler/criterion.rs) to permit the latest version.
- [Changelog](https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bheisler/criterion.rs/compare/0.4.0...0.5.1)

---
updated-dependencies:
- dependency-name: criterion
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-07 01:39:35 +09:00
John Nunley 9e986e614a
v4.0.2
Signed-off-by: John Nunley <dev@notgull.net>
2024-01-01 12:13:55 -08:00
Anton e0c8290f0d
bugfix: Avoid spinning when waiting for deadline 2023-12-25 07:30:31 -08:00
John Nunley ea0f6016ea
v4.0.1
Signed-off-by: John Nunley <dev@notgull.net>
2023-12-19 08:40:55 -08:00
John Nunley c2d1ccb7ae
bugfix: Remove listener if one already exists
This commit makes it so EventListener::listen() does not overwrite
existing listeners if they already exist. If the listener is already
registered in an event listener list, it removes the listener from that
list before registering the new listener. This soundness bug was missed
during #94.

This is a patch-compatible fix for #100. We may also want an API-level
fix for #100 as well. This is up for further discussion.

Signed-off-by: John Nunley <dev@notgull.net>
2023-12-18 07:28:51 -08:00
John Nunley cc33cc5467
Bump MSRV to 1.61 (#102)
This commit also adds portable-atomic tests for MIRI.

Signed-off-by: John Nunley <dev@notgull.net>
2023-12-16 12:44:52 -08:00
John Nunley 531c106f0e
v4.0.0
Signed-off-by: John Nunley <dev@notgull.net>
2023-11-19 09:38:08 -08:00
John Nunley 21b34bf6dd
breaking: Fix the EventListener::new() footgun
This is a breaking change. It makes `new()` take no parameters in its
signature and `listen()` take a reference to an event in its signature.
This should avoid a footgun where a listener can be waited on without
listening on it.

Closes #91

Signed-off-by: John Nunley <dev@notgull.net>
2023-11-15 06:01:17 -08:00
John Nunley e6ec597886
v3.1.0
Signed-off-by: John Nunley <dev@notgull.net>
2023-11-12 16:14:53 -08:00
Pierre Krieger 3f0d516c80
feat: Implement `UnwindSafe` for `EventListener` 2023-11-12 12:49:31 -08:00
dependabot[bot] c42dc40785 Update futures-lite requirement from 1.12.0 to 2.0.0
Updates the requirements on [futures-lite](https://github.com/smol-rs/futures-lite) to permit the latest version.
- [Release notes](https://github.com/smol-rs/futures-lite/releases)
- [Changelog](https://github.com/smol-rs/futures-lite/blob/master/CHANGELOG.md)
- [Commits](https://github.com/smol-rs/futures-lite/compare/v1.12.0...v2.0.0)

---
updated-dependencies:
- dependency-name: futures-lite
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-31 02:17:33 +09:00