Skip to content

Commit b9ed2b0

Browse files
committed
Consolidate all the pub aync utils to native_async
1 parent 7913593 commit b9ed2b0

12 files changed

Lines changed: 44 additions & 43 deletions

File tree

fuzz/src/chanmon_consistency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ use lightning::sign::{
7474
SignerProvider,
7575
};
7676
use lightning::types::payment::{PaymentHash, PaymentPreimage, PaymentSecret};
77-
use lightning::util::async_poll::{MaybeSend, MaybeSync};
7877
use lightning::util::config::UserConfig;
7978
use lightning::util::errors::APIError;
8079
use lightning::util::hash_tables::*;
8180
use lightning::util::logger::Logger;
81+
use lightning::util::native_async::{MaybeSend, MaybeSync};
8282
use lightning::util::ser::{LengthReadable, ReadableArgs, Writeable, Writer};
8383
use lightning::util::test_channel_signer::{EnforcementState, SignerOp, TestChannelSigner};
8484
use lightning::util::test_utils::TestWalletSource;

fuzz/src/full_stack.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ use lightning::sign::{
6363
SignerProvider,
6464
};
6565
use lightning::types::payment::{PaymentHash, PaymentPreimage, PaymentSecret};
66-
use lightning::util::async_poll::{MaybeSend, MaybeSync};
6766
use lightning::util::config::{ChannelConfig, UserConfig};
6867
use lightning::util::hash_tables::*;
6968
use lightning::util::logger::Logger;
69+
use lightning::util::native_async::{MaybeSend, MaybeSync};
7070
use lightning::util::ser::{Readable, Writeable};
7171
use lightning::util::test_channel_signer::{EnforcementState, TestChannelSigner};
7272
use lightning::util::test_utils::TestWalletSource;
@@ -1954,8 +1954,8 @@ pub fn write_fst_seeds(path: &str) {
19541954

19551955
#[cfg(test)]
19561956
mod tests {
1957-
use lightning::util::async_poll::{MaybeSend, MaybeSync};
19581957
use lightning::util::logger::{Logger, Record};
1958+
use lightning::util::native_async::{MaybeSend, MaybeSync};
19591959
use std::collections::HashMap;
19601960
use std::sync::{Arc, Mutex};
19611961

lightning-background-processor/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ use lightning::routing::utxo::UtxoLookup;
5555
#[cfg(not(c_bindings))]
5656
use lightning::sign::EntropySource;
5757
use lightning::sign::{ChangeDestinationSource, ChangeDestinationSourceSync, OutputSpender};
58-
#[cfg(not(c_bindings))]
59-
use lightning::util::async_poll::MaybeSend;
6058
use lightning::util::logger::Logger;
59+
#[cfg(not(c_bindings))]
60+
use lightning::util::native_async::MaybeSend;
6161
use lightning::util::persist::{
6262
KVStore, KVStoreSync, KVStoreSyncWrapper, CHANNEL_MANAGER_PERSISTENCE_KEY,
6363
CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE, CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE,

lightning/src/chain/chainmonitor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ use crate::sign::ecdsa::EcdsaChannelSigner;
5151
use crate::sign::{EntropySource, PeerStorageKey, SignerProvider};
5252
use crate::sync::{Mutex, MutexGuard, RwLock, RwLockReadGuard};
5353
use crate::types::features::{InitFeatures, NodeFeatures};
54-
use crate::util::async_poll::{MaybeSend, MaybeSync};
5554
use crate::util::errors::APIError;
5655
use crate::util::logger::{Logger, WithContext};
57-
use crate::util::native_async::FutureSpawner;
56+
use crate::util::native_async::{FutureSpawner, MaybeSend, MaybeSync};
5857
use crate::util::persist::{KVStore, MonitorName, MonitorUpdatingPersisterAsync};
5958
#[cfg(peer_storage)]
6059
use crate::util::ser::{VecWriter, Writeable};

lightning/src/ln/funding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::ln::msgs;
2222
use crate::ln::types::ChannelId;
2323
use crate::ln::LN_MAX_MSG_LEN;
2424
use crate::prelude::*;
25-
use crate::util::async_poll::MaybeSend;
25+
use crate::util::native_async::MaybeSend;
2626
use crate::util::wallet_utils::{
2727
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, Input,
2828
};

lightning/src/sign/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use crate::ln::script::ShutdownScript;
5656
use crate::offers::invoice::UnsignedBolt12Invoice;
5757
use crate::types::features::ChannelTypeFeatures;
5858
use crate::types::payment::PaymentPreimage;
59-
use crate::util::async_poll::MaybeSend;
59+
use crate::util::native_async::MaybeSend;
6060
use crate::util::ser::{ReadableArgs, Writeable};
6161
use crate::util::transaction_utils;
6262

lightning/src/util/async_poll.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -164,31 +164,3 @@ const DUMMY_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(
164164
pub(crate) fn dummy_waker() -> Waker {
165165
unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &DUMMY_WAKER_VTABLE)) }
166166
}
167-
168-
/// Marker trait to optionally implement `Sync` under std.
169-
///
170-
/// This is not exported to bindings users as async is only supported in Rust.
171-
#[cfg(feature = "std")]
172-
pub use core::marker::Sync as MaybeSync;
173-
174-
#[cfg(not(feature = "std"))]
175-
/// Marker trait to optionally implement `Sync` under std.
176-
///
177-
/// This is not exported to bindings users as async is only supported in Rust.
178-
pub trait MaybeSync {}
179-
#[cfg(not(feature = "std"))]
180-
impl<T> MaybeSync for T where T: ?Sized {}
181-
182-
/// Marker trait to optionally implement `Send` under std.
183-
///
184-
/// This is not exported to bindings users as async is only supported in Rust.
185-
#[cfg(feature = "std")]
186-
pub use core::marker::Send as MaybeSend;
187-
188-
#[cfg(not(feature = "std"))]
189-
/// Marker trait to optionally implement `Send` under std.
190-
///
191-
/// This is not exported to bindings users as async is only supported in Rust.
192-
pub trait MaybeSend {}
193-
#[cfg(not(feature = "std"))]
194-
impl<T> MaybeSend for T where T: ?Sized {}

lightning/src/util/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub mod mut_global;
2020

2121
pub mod anchor_channel_reserves;
2222

23-
pub mod async_poll;
23+
pub(crate) mod async_poll;
2424
#[cfg(fuzzing)]
2525
pub mod base32;
2626
#[cfg(not(fuzzing))]

lightning/src/util/native_async.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
1010
#[cfg(all(test, feature = "std"))]
1111
use crate::sync::{Arc, Mutex};
12-
use crate::util::async_poll::{MaybeSend, MaybeSync};
1312

13+
#[cfg(test)]
14+
use alloc::boxed::Box;
1415
#[cfg(all(test, not(feature = "std")))]
1516
use alloc::rc::Rc;
1617

@@ -53,6 +54,34 @@ trait MaybeSendableFuture: Future<Output = ()> + MaybeSend + 'static {}
5354
#[cfg(test)]
5455
impl<F: Future<Output = ()> + MaybeSend + 'static> MaybeSendableFuture for F {}
5556

57+
/// Marker trait to optionally implement `Sync` under std.
58+
///
59+
/// This is not exported to bindings users as async is only supported in Rust.
60+
#[cfg(feature = "std")]
61+
pub use core::marker::Sync as MaybeSync;
62+
63+
#[cfg(not(feature = "std"))]
64+
/// Marker trait to optionally implement `Sync` under std.
65+
///
66+
/// This is not exported to bindings users as async is only supported in Rust.
67+
pub trait MaybeSync {}
68+
#[cfg(not(feature = "std"))]
69+
impl<T> MaybeSync for T where T: ?Sized {}
70+
71+
/// Marker trait to optionally implement `Send` under std.
72+
///
73+
/// This is not exported to bindings users as async is only supported in Rust.
74+
#[cfg(feature = "std")]
75+
pub use core::marker::Send as MaybeSend;
76+
77+
#[cfg(not(feature = "std"))]
78+
/// Marker trait to optionally implement `Send` under std.
79+
///
80+
/// This is not exported to bindings users as async is only supported in Rust.
81+
pub trait MaybeSend {}
82+
#[cfg(not(feature = "std"))]
83+
impl<T> MaybeSend for T where T: ?Sized {}
84+
5685
/// A simple [`FutureSpawner`] which holds [`Future`]s until they are manually polled via
5786
/// [`Self::poll_futures`].
5887
#[cfg(all(test, feature = "std"))]

lightning/src/util/persist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ use crate::ln::types::ChannelId;
3838
use crate::sign::{ecdsa::EcdsaChannelSigner, EntropySource, SignerProvider};
3939
use crate::sync::Mutex;
4040
use crate::util::async_poll::{
41-
dummy_waker, MaybeSend, MaybeSync, MultiResultFuturePoller, ResultFuture, TwoFutureJoiner,
41+
dummy_waker, MultiResultFuturePoller, ResultFuture, TwoFutureJoiner,
4242
};
4343
use crate::util::logger::Logger;
44-
use crate::util::native_async::FutureSpawner;
44+
use crate::util::native_async::{FutureSpawner, MaybeSend, MaybeSync};
4545
use crate::util::ser::{Readable, ReadableArgs, Writeable};
4646
use crate::util::wakers::Notifier;
4747

0 commit comments

Comments
 (0)