Need help with event-listener?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

166 Stars 12 Forks Other 66 Commits 3 Opened issues


Notify async tasks or threads

Services available


Need anything else?

Contributors list


Build License Cargo Documentation

Notify async tasks or threads.

This is a synchronization primitive similar to eventcounts invented by Dmitry Vyukov.

You can use this crate to turn non-blocking data structures into async or blocking data structures. See a simple mutex implementation that exposes an async and a blocking interface for acquiring locks.


Wait until another thread sets a boolean flag:

use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use event_listener::Event;

let flag = Arc::new(AtomicBool::new(false)); let event = Arc::new(Event::new());

// Spawn a thread that will set the flag after 1 second. thread::spawn({ let flag = flag.clone(); let event = event.clone(); move || { // Wait for a second. thread::sleep(Duration::from_secs(1));

    // Set the flag., Ordering::SeqCst);

    // Notify all listeners that the flag has been set.


// Wait until the flag is set. loop { // Check the flag. if flag.load(Ordering::SeqCst) { break; }

// Start listening for events.
let listener = event.listen();

// Check the flag again after creating the listener.
if flag.load(Ordering::SeqCst) {

// Wait for a notification and continue the loop.



Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or
  • MIT license (LICENSE-MIT or

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.