Skip to content

Commit 75ed8c8

Browse files
author
Hyunsik Jeong
committed
Make TimerLoop::new to return Arc<TimerLoop>
1 parent 3f10c26 commit 75ed8c8

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

codechain/run_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use crate::json::PasswordFile;
4646
use crate::rpc::{rpc_http_start, rpc_ipc_start, rpc_ws_start};
4747
use crate::rpc_apis::ApiDependencies;
4848

49-
fn network_start(timer_loop: TimerLoop, cfg: &NetworkConfig) -> Result<Arc<NetworkService>, String> {
49+
fn network_start(timer_loop: Arc<TimerLoop>, cfg: &NetworkConfig) -> Result<Arc<NetworkService>, String> {
5050
cinfo!(NETWORK, "Handshake Listening on {}:{}", cfg.address, cfg.port);
5151

5252
let addr = cfg.address.parse().map_err(|_| format!("Invalid NETWORK listen host given: {}", cfg.address))?;

network/src/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl Api for ClientApi {
8282
pub struct Client {
8383
extensions: RwLock<HashMap<&'static str, Arc<NetworkExtension>>>,
8484
p2p_channel: IoChannel<P2pMessage>,
85-
timer_loop: TimerLoop,
85+
timer_loop: Arc<TimerLoop>,
8686
}
8787

8888
macro_rules! define_broadcast_method {
@@ -137,7 +137,7 @@ impl Client {
137137
}
138138

139139
#[cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))]
140-
pub fn new(p2p_channel: IoChannel<P2pMessage>, timer_loop: TimerLoop) -> Arc<Self> {
140+
pub fn new(p2p_channel: IoChannel<P2pMessage>, timer_loop: Arc<TimerLoop>) -> Arc<Self> {
141141
Arc::new(Self {
142142
extensions: RwLock::new(HashMap::new()),
143143
p2p_channel,

network/src/service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub struct Service {
4242

4343
impl Service {
4444
pub fn start(
45-
timer_loop: TimerLoop,
45+
timer_loop: Arc<TimerLoop>,
4646
address: SocketAddr,
4747
min_peers: usize,
4848
max_peers: usize,

util/timer/src/timer.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ pub struct TimerLoop {
4242
}
4343

4444
impl TimerLoop {
45-
pub fn new(worker_size: usize) -> TimerLoop {
45+
#[cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))]
46+
pub fn new(worker_size: usize) -> Arc<Self> {
4647
let timers = Arc::new(RwLock::new(HashMap::new()));
4748
let scheduler = Arc::new(Scheduler::new());
4849

@@ -56,10 +57,10 @@ impl TimerLoop {
5657
.unwrap();
5758
}
5859

59-
TimerLoop {
60+
Arc::new(Self {
6061
timers,
6162
scheduler,
62-
}
63+
})
6364
}
6465

6566
pub fn new_timer<T>(&self, name: TimerName, handler: Arc<T>) -> TimerApi

0 commit comments

Comments
 (0)