Skip to content

Commit

Permalink
Review tokio runtime being used (#875)
Browse files Browse the repository at this point in the history
* Review tokio runtime being used

* Fix cargo clippy
  • Loading branch information
Mallets authored Apr 1, 2024
1 parent 05b9cb4 commit 51f4f1c
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion io/zenoh-links/zenoh-link-tcp/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl LinkUnicastTrait for LinkUnicastTcp {
// impl Drop for LinkUnicastTcp {
// fn drop(&mut self) {
// // Close the underlying TCP socket
// zenoh_runtime::ZRuntime::TX.block_in_place(async {
// zenoh_runtime::ZRuntime::Acceptor.block_in_place(async {
// let _ = self.get_mut_socket().shutdown().await;
// });
// }
Expand Down
4 changes: 2 additions & 2 deletions io/zenoh-links/zenoh-link-tls/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ impl Drop for LinkUnicastTls {
fn drop(&mut self) {
// Close the underlying TCP stream
let (tcp_stream, _) = self.get_sock_mut().get_mut();
let _ =
zenoh_runtime::ZRuntime::TX.block_in_place(async move { tcp_stream.shutdown().await });
let _ = zenoh_runtime::ZRuntime::Acceptor
.block_in_place(async move { tcp_stream.shutdown().await });
}
}

Expand Down
2 changes: 1 addition & 1 deletion io/zenoh-links/zenoh-link-unixsock_stream/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl LinkUnicastTrait for LinkUnicastUnixSocketStream {
impl Drop for LinkUnicastUnixSocketStream {
fn drop(&mut self) {
// Close the underlying UnixSocketStream socket
let _ = zenoh_runtime::ZRuntime::TX
let _ = zenoh_runtime::ZRuntime::Acceptor
.block_in_place(async move { self.get_mut_socket().shutdown().await });
}
}
Expand Down
2 changes: 1 addition & 1 deletion io/zenoh-links/zenoh-link-ws/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl LinkUnicastTrait for LinkUnicastWs {

impl Drop for LinkUnicastWs {
fn drop(&mut self) {
zenoh_runtime::ZRuntime::TX.block_in_place(async {
zenoh_runtime::ZRuntime::Acceptor.block_in_place(async {
let mut guard = zasynclock!(self.send);
// Close the underlying TCP socket
guard.close().await.unwrap_or_else(|e| {
Expand Down
4 changes: 2 additions & 2 deletions io/zenoh-transport/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ impl TransportManager {

// TODO(yuyuan): Can we make this async as above?
pub fn get_locators(&self) -> Vec<Locator> {
let mut lsu = zenoh_runtime::ZRuntime::TX.block_in_place(self.get_locators_unicast());
let mut lsm = zenoh_runtime::ZRuntime::TX.block_in_place(self.get_locators_multicast());
let mut lsu = zenoh_runtime::ZRuntime::Net.block_in_place(self.get_locators_unicast());
let mut lsm = zenoh_runtime::ZRuntime::Net.block_in_place(self.get_locators_multicast());
lsu.append(&mut lsm);
lsu
}
Expand Down
2 changes: 1 addition & 1 deletion io/zenoh-transport/src/unicast/universal/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl TransportLinkUnicastUniversal {
// to finish in the close() joining its handle
// TODO(yuyuan): do more study to check which ZRuntime should be used or refine the
// termination
zenoh_runtime::ZRuntime::TX
zenoh_runtime::ZRuntime::Net
.spawn(async move { transport.del_link(tx.inner.link()).await });
}
};
Expand Down
2 changes: 1 addition & 1 deletion zenoh-ext/src/publication_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl<'a> PublicationCache<'a> {
let token = TerminatableTask::create_cancellation_token();
let token2 = token.clone();
let task = TerminatableTask::spawn(
zenoh_runtime::ZRuntime::TX,
zenoh_runtime::ZRuntime::Application,
async move {
let mut cache: HashMap<OwnedKeyExpr, VecDeque<Sample>> =
HashMap::with_capacity(resources_limit.unwrap_or(32));
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/hat/p2p_peer/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ impl Network {

if !self.autoconnect.is_empty() {
// Connect discovered peers
if zenoh_runtime::ZRuntime::Net
if zenoh_runtime::ZRuntime::Acceptor
.block_in_place(strong_runtime.manager().get_transport_unicast(&zid))
.is_none()
&& self.autoconnect.matches(whatami)
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/scouting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ fn scout(
let cancellation_token = TerminatableTask::create_cancellation_token();
let cancellation_token_clone = cancellation_token.clone();
let task = TerminatableTask::spawn(
zenoh_runtime::ZRuntime::Net,
zenoh_runtime::ZRuntime::Acceptor,
async move {
let scout = Runtime::scout(&sockets, what, &addr, move |hello| {
let callback = callback.clone();
Expand Down
4 changes: 2 additions & 2 deletions zenoh/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ impl Session {
// Cannot hold session lock when calling tables (matching_status())
// TODO: check which ZRuntime should be used
self.task_controller
.spawn_with_rt(zenoh_runtime::ZRuntime::RX, {
.spawn_with_rt(zenoh_runtime::ZRuntime::Net, {
let session = self.clone();
let msub = msub.clone();
async move {
Expand Down Expand Up @@ -1546,7 +1546,7 @@ impl Session {
// Cannot hold session lock when calling tables (matching_status())
// TODO: check which ZRuntime should be used
self.task_controller
.spawn_with_rt(zenoh_runtime::ZRuntime::RX, {
.spawn_with_rt(zenoh_runtime::ZRuntime::Net, {
let session = self.clone();
let msub = msub.clone();
async move {
Expand Down

0 comments on commit 51f4f1c

Please sign in to comment.