pub struct LocalScope { /* private fields */ }Expand description
Holds subscriptions whose callbacks run on this thread, when you pump.
Ordinary subscriptions hand their callback to the library, which may call it
from the file watcher’s thread - so the callback has to be Send + Sync,
which rules out Rc state and most GUI context handles. A local
subscription instead queues the value and calls the callback from
LocalScope::drain, on whichever thread drains.
The scope is neither Send nor Sync, so a callback registered here cannot
reach another thread at all - not by convention, but because the type will
not move.
Dropping the scope ends every subscription in it.
Implementations§
Source§impl LocalScope
impl LocalScope
pub fn new() -> Self
Sourcepub fn drain(&mut self)
pub fn drain(&mut self)
Delivers everything queued since the last call.
Changes a callback causes while draining are picked up by the next drain, not this one, so a callback that writes what it listens to cannot spin here.