title: How do I inform Tokio about an event in a C-owned thread?
body: <p>I use a C library which provides an API to call user provided function in a thread created by that C library. I cannot handle events inside the callback because it should not block the thread, so I want some way to inform the Tokio event loop that my callback was called.</p>
  
  <p>How can I do that?</p>
  
  <p>More precisely I have:</p>
  
  <pre><code>fn register_callback_to_run_inside_c_thread&lt;F&gt;(callback_f: F)
  where
      F: FnMut() + Send + UnwindSafe + 'static,
  {
      unimplemented!();
  }
  </code></pre>
  
  <p>I want to pass a closure inside <code>register_callback_to_run_inside_c_thread</code> to inform Tokio about the event.</p>
  
  <p>First I tried:</p>
  
  <pre><code>let (mut tx, rx) = watch::channel("hello");
  register_callback_to_run_inside_c_thread(move || {
      tx.broadcast("world").unwrap();
  });
  </code></pre>
  
  <p>This code doesn't compile because it uses <code>RefCell</code> somewhere inside.</p>
  
  <p>I also tried to use <code>lazy</code> to start a function inside Tokio. That code compiles, but crashes during runtime because <code>lazy</code> should be executed inside threads created by Tokio but the callback runs inside a thread created by the C library.</p>
  
  <p>Is there any way to inform Tokio about the event?</p>