Skip to content

Commit f7186ef

Browse files
committed
Consolidate all the pub aync utils to native_async
1 parent e66b458 commit f7186ef

File tree

10 files changed

+41
-40
lines changed

10 files changed

+41
-40
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ use lightning::routing::utxo::UtxoLookup;
5353
use lightning::sign::{
5454
ChangeDestinationSource, ChangeDestinationSourceSync, EntropySource, OutputSpender,
5555
};
56-
#[cfg(not(c_bindings))]
57-
use lightning::util::async_poll::MaybeSend;
5856
use lightning::util::logger::Logger;
5957
use lightning::util::persist::{
6058
KVStore, KVStoreSync, KVStoreSyncWrapper, CHANNEL_MANAGER_PERSISTENCE_KEY,
@@ -63,6 +61,8 @@ use lightning::util::persist::{
6361
NETWORK_GRAPH_PERSISTENCE_SECONDARY_NAMESPACE, SCORER_PERSISTENCE_KEY,
6462
SCORER_PERSISTENCE_PRIMARY_NAMESPACE, SCORER_PERSISTENCE_SECONDARY_NAMESPACE,
6563
};
64+
#[cfg(not(c_bindings))]
65+
use lightning::util::native_async::MaybeSend;
6666
use lightning::util::sweep::{OutputSweeper, OutputSweeperSync};
6767
use lightning::util::wakers::Future;
6868
#[cfg(feature = "std")]

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/events/bump_transaction/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use crate::sign::{
3737
ChannelDerivationParameters, HTLCDescriptor, SignerProvider, P2WPKH_WITNESS_WEIGHT,
3838
};
3939
use crate::sync::Mutex;
40-
use crate::util::async_poll::{MaybeSend, MaybeSync};
40+
use crate::util::native_async::{MaybeSend, MaybeSync};
4141
use crate::util::logger::Logger;
4242

4343
use bitcoin::amount::Amount;

lightning/src/events/bump_transaction/sync.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ use crate::chain::chaininterface::BroadcasterInterface;
1818
use crate::chain::ClaimId;
1919
use crate::prelude::*;
2020
use crate::sign::SignerProvider;
21-
use crate::util::async_poll::{dummy_waker, MaybeSend, MaybeSync};
21+
use crate::util::async_poll::dummy_waker;
2222
use crate::util::logger::Logger;
23+
use crate::util::native_async::{MaybeSend, MaybeSync};
2324

2425
use bitcoin::{Psbt, ScriptBuf, Transaction, TxOut};
2526

lightning/src/sign/mod.rs

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

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
@@ -37,10 +37,10 @@ use crate::ln::types::ChannelId;
3737
use crate::sign::{ecdsa::EcdsaChannelSigner, EntropySource, SignerProvider};
3838
use crate::sync::Mutex;
3939
use crate::util::async_poll::{
40-
dummy_waker, MaybeSend, MaybeSync, MultiResultFuturePoller, ResultFuture, TwoFutureJoiner,
40+
dummy_waker, MultiResultFuturePoller, ResultFuture, TwoFutureJoiner,
4141
};
4242
use crate::util::logger::Logger;
43-
use crate::util::native_async::FutureSpawner;
43+
use crate::util::native_async::{FutureSpawner, MaybeSend, MaybeSync};
4444
use crate::util::ser::{Readable, ReadableArgs, Writeable};
4545
use crate::util::wakers::Notifier;
4646

lightning/src/util/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ use crate::sign::{self, ReceiveAuthKey};
5151
use crate::sign::{ChannelSigner, PeerStorageKey};
5252
use crate::sync::RwLock;
5353
use crate::types::features::{ChannelFeatures, InitFeatures, NodeFeatures};
54-
use crate::util::async_poll::MaybeSend;
5554
use crate::util::config::UserConfig;
5655
use crate::util::dyn_signer::{
5756
DynKeysInterface, DynKeysInterfaceTrait, DynPhantomKeysInterface, DynSigner,
5857
};
5958
use crate::util::logger::{Logger, Record};
6059
#[cfg(feature = "std")]
6160
use crate::util::mut_global::MutGlobal;
61+
use crate::util::native_async::MaybeSend;
6262
use crate::util::persist::{KVStore, KVStoreSync, MonitorName};
6363
use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer};
6464
use crate::util::test_channel_signer::{EnforcementState, TestChannelSigner};

0 commit comments

Comments
 (0)