flutter_rust_bridge icon indicating copy to clipboard operation
flutter_rust_bridge copied to clipboard

Cancelable tasks and object pools

Open fzyzcjy opened this issue 2 years ago • 7 comments

  • [ ] cancellable tasks
  • [ ] object pools (dependent of cancellable task)

Fix #241 Fix #242

fzyzcjy avatar Feb 12 '22 09:02 fzyzcjy

Current status: need some work to make it compile...

Main problem to consider: In my private repo api.rs I have the following code and let frb generate everything for me. However, now since it is extracted into frb itself, I need to reconsider how to write this code.

#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub struct CancelTokenHandle(pub i64, pub i64);

impl_pool_object_handle!(Arc<CancelToken>, CancelTokenHandle);

pub fn cancel_token_new(sub_pool_id: i64) -> Result<CancelTokenHandle> {
    Ok(pool::put(sub_pool_id, Arc::new(CancelToken::new())))
}

pub fn cancel_token_cancel(cancel_token: CancelTokenHandle) -> Result<()> {
    let cancel_token = pool::get_cloned(cancel_token)?;
    cancel_token.cancel();
    Ok(())
}

pub fn cancel_token_remove(cancel_token: CancelTokenHandle) -> Result<()> {
    pool::remove(cancel_token);
    Ok(())
}

fzyzcjy avatar Feb 12 '22 09:02 fzyzcjy

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 08 '22 02:05 stale[bot]

👀

sagudev avatar May 08 '22 05:05 sagudev

@sagudev You are welcomed to make a PR to make this work :) Because I have already done the main things, and the blocking issue is https://github.com/fzyzcjy/flutter_rust_bridge/pull/333#issuecomment-1037079219

fzyzcjy avatar May 08 '22 10:05 fzyzcjy

👀

I did this just to prevent stale.

sagudev avatar May 08 '22 10:05 sagudev

👀

lattice0 avatar Jul 09 '22 02:07 lattice0

@lattice0 Feel free to implement :) https://github.com/fzyzcjy/flutter_rust_bridge/pull/333#issuecomment-1037079219

fzyzcjy avatar Jul 09 '22 03:07 fzyzcjy

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 07 '22 04:11 stale[bot]

Is there any chance, that cancelable tasks will be implemented in the near future?

LowLevelSubmarine avatar Nov 05 '23 23:11 LowLevelSubmarine

@LowLevelSubmarine You can copy-and-paste it into your api.rs currently!

fzyzcjy avatar Nov 05 '23 23:11 fzyzcjy