-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[r2r] Stop spawned futures #1490
Conversation
* Add `MmCoin::spawn`
* Add `SpawnSettings`
* Store abort handles by associated `FutureId` not to keep them forever * Remove `wio::Timeout`
* Add `FutureSpawner` trait to `executor`
* Kick-start swaps by spawning them as futures, not as threads * Remove `common::executor::spawn_boxed` * Delete `common/executor.rs` file
* Leave Spawn traits in `spawner.rs` only * Add `AbortableSpawnerWeak` * Rename `CoinFutureSpawner` to `CoinFutSpawner` * Rename `MmSpawner` to `MmFutSpawner`
* `spawn_gossipsub` takes an `SwarmRuntime` instance to spawn futures
* Add `SwapWatcherLock` * Remove `SwapsContext::shutdown_rx`
* Remove `spawn_abortable_with_settings`
* Allow to create an abortable subsystem that will be aborted if the linked supersystem is aborted.
* Run `test_mm2_stops_impl` twice
This PR affects the following parts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! That's the first and very brief review iteration. I think I will have quite a few questions on the next one :)
# Conflicts: # mm2src/coins/eth.rs # mm2src/coins/lightning.rs # mm2src/coins/qrc20.rs # mm2src/coins/solana/spl.rs # mm2src/coins/utxo/slp.rs # mm2src/coins/z_coin.rs # mm2src/mm2_main/src/mm2_tests.rs # mm2src/mm2_test_helpers/src/for_tests.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second review, quite brief again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of questions.
* Add `AbortableQueue` field into `ElectrumClientImpl`, `ElectrumConnection` * Pass a spawner to `ws_transport` * Remove `wasm_ws::ClosingState` by replacing it with `ClosedState`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Work! Just reviewed the lightning related parts for now, will review the rest of the PR in more details in the next iteration.
* Increase `WASM_BINDGEN_TEST_TIMEOUT` to 180 seconds * Avoid unnecessary `spawn` usage
* Avoid using `allow(dead_code)` * Add `spawn_local_abortable` to `wasm_executor` * Avoid unnecessary `spawn_local` usage at `webusb_driver`
@artemii235 @shamardy PR is ready for the next review iteration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next iteration.
@sergeyboyko0791 Also a question: should we maybe call spawner().abort_all()
in the disable_coin
RPC?
This definitely makes sense as some futures may hold a shared pointer to the coin. But I think we first need to fix #1493
I can leave a comment in this issue cc: @artemii235 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
/// It's used to spawn futures that can be aborted immediately or after a timeout | ||
/// on the [`MmArc::stop`] function call. | ||
pub abortable_system: AbortableQueue, | ||
/// The abortable system is pinned to the `MmCtx` context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this great enhancement!
// Notify shutdown listeners. | ||
self.graceful_shutdown_registry.abort_all(); | ||
// Abort spawned futures. | ||
self.abortable_system.abort_all(); | ||
|
||
#[cfg(not(target_arch = "wasm32"))] | ||
self.background_processors.lock().unwrap().drain(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess background processors can be moved back to LightningCoin
as before since they will be dropped now with the coins on calling stop, I added this to the lightning integration checklist #1045 (comment)
AbortableSystem
with the ability to create Future subsystemsMmFutSpawner
withinmm2_libp2p::AtomicDexBehaviour