浏览代码

Remove the generic parameter of DaemonEnv.

The same data is stored for all types of content.
Jing Yang 4 年之前
父节点
当前提交
4c11a4913d
共有 2 个文件被更改,包括 7 次插入9 次删除
  1. 6 8
      src/daemon_env.rs
  2. 1 1
      src/lib.rs

+ 6 - 8
src/daemon_env.rs

@@ -1,4 +1,3 @@
-use std::marker::PhantomData;
 use std::sync::Arc;
 
 use parking_lot::Mutex;
@@ -21,15 +20,14 @@ macro_rules! check_or_record {
 }
 
 #[derive(Clone, Debug, Default)]
-pub(crate) struct DaemonEnv<T> {
-    data: Arc<Mutex<DaemonEnvData<T>>>,
+pub(crate) struct DaemonEnv {
+    data: Arc<Mutex<DaemonEnvData>>,
 }
 
 #[derive(Debug, Default)]
-struct DaemonEnvData<T> {
+struct DaemonEnvData {
     errors: Vec<Error>,
     daemons: Vec<std::thread::JoinHandle<()>>,
-    phantom: PhantomData<T>,
 }
 
 #[derive(Debug)]
@@ -45,8 +43,8 @@ pub(crate) enum ErrorKind {
     RollbackCommitted(usize),
 }
 
-impl<T> DaemonEnv<T> {
-    pub fn record_error<S: AsRef<str>>(
+impl DaemonEnv {
+    pub fn record_error<T, S: AsRef<str>>(
         &self,
         error_kind: ErrorKind,
         message: S,
@@ -109,7 +107,7 @@ impl<T> DaemonEnv<T> {
         }
     }
 
-    fn strip_data(raft: &RaftState<T>) -> StrippedRaftState {
+    fn strip_data<T>(raft: &RaftState<T>) -> StrippedRaftState {
         StrippedRaftState {
             current_term: raft.current_term,
             voted_for: raft.voted_for,

+ 1 - 1
src/lib.rs

@@ -81,7 +81,7 @@ pub struct Raft<Command> {
 
     thread_pool: Arc<tokio::runtime::Runtime>,
 
-    daemon_env: DaemonEnv<Command>,
+    daemon_env: DaemonEnv,
     stop_wait_group: WaitGroup,
 }