pub struct CancellationController { /* private fields */ }Expand description
Owner-side handle for broadcasting cancellation to running turns.
Create one CancellationController per agent and hand out
CancellationHandles to the loop and tool executors. Calling
interrupt bumps an internal generation counter so that
every outstanding TurnCancellation checkpoint becomes cancelled.
§Example
use agentkit_core::CancellationController;
let controller = CancellationController::new();
let handle = controller.handle();
// Before an interrupt the generation is 0.
assert_eq!(handle.generation(), 0);
// Signal cancellation (e.g. from a Ctrl-C handler).
controller.interrupt();
assert_eq!(handle.generation(), 1);Implementations§
Source§impl CancellationController
impl CancellationController
Sourcepub fn handle(&self) -> CancellationHandle
pub fn handle(&self) -> CancellationHandle
Returns a cloneable CancellationHandle that shares state with this controller.
Sourcepub fn interrupt(&self) -> u64
pub fn interrupt(&self) -> u64
Broadcasts a cancellation by incrementing the generation counter.
Returns the new generation value. All TurnCancellation checkpoints
created before this call will report themselves as cancelled.
Trait Implementations§
Source§impl Clone for CancellationController
impl Clone for CancellationController
Source§fn clone(&self) -> CancellationController
fn clone(&self) -> CancellationController
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for CancellationController
impl Default for CancellationController
Source§fn default() -> CancellationController
fn default() -> CancellationController
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CancellationController
impl RefUnwindSafe for CancellationController
impl Send for CancellationController
impl Sync for CancellationController
impl Unpin for CancellationController
impl UnsafeUnpin for CancellationController
impl UnwindSafe for CancellationController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more