Commit Graph

15 Commits

Author SHA1 Message Date
Jacob Rothstein f402b7e24c feat: Add a loom implementation for event-listener 2024-03-30 12:00:55 -07: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 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 c278371cfb
feat: Add explicit web support
This commit adds WASM compilation support to this crate. The main thing
is that the wait() family of APIs are removed in WASM mode, as blocking
is not allowed in WASM.

In addition, tests are added to CI to support WASM.

Signed-off-by: John Nunley <dev@notgull.net>
2023-08-26 12:53:39 -07:00
jtnunley 6345794547 Make the notify() function return notified count
Fix off-by-one error in implementation
2023-05-17 15:12:13 -07:00
jtnunley 1ec136a8a5 Unsplit the 'Incomplete' commit 2023-03-31 13:42:55 -07:00
jtnunley 996ee4d4f9 EventListener is now used through pinning
The EventListener for the upcoming libstd-based implementation needs to
be pinned, so this commit sets up the infrastructure for the pinned
EventListener.

This is a breaking change.
2023-03-31 13:19:06 -07:00
jtnunley 9e3217767d Move inner data to lib.rs 2023-03-30 09:14:22 -07:00
John Nunley 0235e55a0f
Replace the linked list with a safer and less allocation-heavy alternative (#38)
* Use slab to avoid unsafe code

* Move send+sync impls down to Mutex

* Code review

* Unwrap the key earlier

* Reduce the scope of one of the unsafe blocks.
2022-11-21 08:42:27 -08:00
John Nunley 16b3d599fc
Implement an algorithm to make this crate no_std, take 3 (#34) 2022-11-11 07:53:43 -08:00
Stjepan Glavina 2f7b3269a5 Bump to v2.0.1 2020-06-24 02:04:48 +02:00
Stjepan Glavina c70de0047c Cleaner API and relaxed variants 2020-05-27 13:04:55 +02:00
Stjepan Glavina 5dcdd8d0d3 Add notify_additional() 2020-05-25 12:50:06 +02:00
Stjepan Glavina bb936fc027 Bring back listen() 2020-05-25 00:27:43 +02:00
Stjepan Glavina 9d6b58087c Add tests 2020-05-20 21:13:35 +02:00