Skip to content

Commit 6bd5904

Browse files
authored
Merge pull request #9191 from BohuTANG/dev-runtime
refactor: move runtime related to base/runtime
2 parents 68ea86c + 660c0e8 commit 6bd5904

File tree

58 files changed

+129
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+129
-111
lines changed

src/binaries/query/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
use std::env;
1616

17-
use common_base::base::Runtime;
18-
use common_base::base::GLOBAL_MEM_STAT;
17+
use common_base::runtime::Runtime;
18+
use common_base::runtime::GLOBAL_MEM_STAT;
1919
use common_config::Config;
2020
use common_config::DATABEND_COMMIT_VERSION;
2121
use common_config::QUERY_SEMVER;

src/common/base/src/base/mod.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,22 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
mod catch_unwind;
16-
mod global_runtime;
1715
mod net;
1816
mod profiling;
1917
mod progress;
20-
mod runtime;
21-
mod runtime_tracker;
2218
mod select;
2319
mod shutdown_signal;
2420
mod singleton_instance;
2521
mod stop_handle;
2622
mod stoppable;
2723
mod string;
28-
mod thread;
29-
mod thread_pool;
3024
mod uniq_id;
3125

32-
pub use catch_unwind::catch_unwind;
33-
pub use global_runtime::GlobalIORuntime;
3426
pub use net::get_free_tcp_port;
3527
pub use net::get_free_udp_port;
3628
pub use profiling::Profiling;
3729
pub use progress::Progress;
3830
pub use progress::ProgressValues;
39-
pub use runtime::Dropper;
40-
pub use runtime::Runtime;
41-
pub use runtime::TrySpawn;
42-
pub use runtime_tracker::MemStat;
43-
pub use runtime_tracker::ThreadTracker;
44-
pub use runtime_tracker::TrackedFuture;
45-
pub use runtime_tracker::GLOBAL_MEM_STAT;
4631
pub use select::select3;
4732
pub use select::Select3Output;
4833
pub use shutdown_signal::signal_stream;
@@ -59,10 +44,6 @@ pub use string::mask_string;
5944
pub use string::replace_nth_char;
6045
pub use string::unescape_for_key;
6146
pub use string::unescape_string;
62-
pub use thread::Thread;
63-
pub use thread::ThreadJoinHandle;
64-
pub use thread_pool::TaskJoinHandler;
65-
pub use thread_pool::ThreadPool;
6647
pub use tokio;
6748
pub use uniq_id::GlobalSequence;
6849
pub use uniq_id::GlobalUniqName;

src/common/base/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ pub mod base;
2525
pub mod containers;
2626
pub mod mem_allocator;
2727
pub mod rangemap;
28+
pub mod runtime;

src/common/base/src/mem_allocator/je_allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub mod linux_or_macos {
4040
use tikv_jemalloc_sys as ffi;
4141

4242
use super::JEAllocator;
43-
use crate::base::ThreadTracker;
43+
use crate::runtime::ThreadTracker;
4444

4545
impl<T> JEAllocator<T> {
4646
pub const FALLBACK: bool = false;

src/common/base/src/mem_allocator/mmap_allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub mod linux {
3636
use std::ptr::NonNull;
3737

3838
use super::MmapAllocator;
39-
use crate::base::ThreadTracker;
39+
use crate::runtime::ThreadTracker;
4040

4141
// MADV_POPULATE_WRITE is supported since Linux 5.14.
4242
const MADV_POPULATE_WRITE: i32 = 23;

src/common/base/src/mem_allocator/system_allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::alloc::Layout;
1818
use std::alloc::System;
1919
use std::ptr::NonNull;
2020

21-
use crate::base::ThreadTracker;
21+
use crate::runtime::ThreadTracker;
2222

2323
#[derive(Debug, Clone, Copy, Default)]
2424
pub struct SystemAllocator;

src/common/base/src/base/global_runtime.rs renamed to src/common/base/src/runtime/global_runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use std::sync::Arc;
1616

1717
use common_exception::Result;
1818

19-
use super::GlobalInstance;
20-
use crate::base::Runtime;
19+
use crate::base::GlobalInstance;
20+
use crate::runtime::Runtime;
2121

2222
pub struct GlobalIORuntime;
2323

src/common/base/src/runtime/mod.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2021 Datafuse Labs.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
mod catch_unwind;
16+
mod global_runtime;
17+
#[allow(clippy::module_inception)]
18+
mod runtime;
19+
mod runtime_tracker;
20+
mod thread;
21+
mod thread_pool;
22+
23+
pub use catch_unwind::catch_unwind;
24+
pub use global_runtime::GlobalIORuntime;
25+
pub use runtime::Dropper;
26+
pub use runtime::Runtime;
27+
pub use runtime::TrySpawn;
28+
pub use runtime_tracker::MemStat;
29+
pub use runtime_tracker::ThreadTracker;
30+
pub use runtime_tracker::TrackedFuture;
31+
pub use runtime_tracker::GLOBAL_MEM_STAT;
32+
pub use thread::Thread;
33+
pub use thread::ThreadJoinHandle;
34+
pub use thread_pool::TaskJoinHandler;
35+
pub use thread_pool::ThreadPool;

src/common/base/src/base/runtime.rs renamed to src/common/base/src/runtime/runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ use tokio::sync::OwnedSemaphorePermit;
2828
use tokio::sync::Semaphore;
2929
use tokio::task::JoinHandle;
3030

31-
use crate::base::catch_unwind::CatchUnwindFuture;
32-
use crate::base::runtime_tracker::MemStat;
31+
use crate::runtime::catch_unwind::CatchUnwindFuture;
32+
use crate::runtime::MemStat;
3333

3434
/// Methods to spawn tasks.
3535
pub trait TrySpawn {

0 commit comments

Comments
 (0)