Johannes Hofmann 7 лет назад
Родитель
Сommit
c64b1bf28e
1 измененных файлов: 5 добавлений и 5 удалений
  1. 5
    5
      src/search.rs

+ 5
- 5
src/search.rs Просмотреть файл

@@ -25,7 +25,7 @@ impl<T, E> From<Result<T, E>> for ControlFlow
25 25
 
26 26
 enum WorkerMessage {
27 27
     PleaseStop,
28
-    DoBlob(Blob),
28
+    DoBlob(Box<Blob>),
29 29
 }
30 30
 
31 31
 pub fn par_search<P, F, G>(
@@ -121,10 +121,10 @@ where P: AsRef<Path>,
121 121
         let mut stopped_threads = 0;
122 122
 
123 123
         // send initial message to each worker thread
124
-        for thread_id in 0..num_threads {
124
+        for channel in &chans {
125 125
             match reader.next() {
126 126
                 Some(Ok(blob)) => {
127
-                    chans[thread_id].send(WorkerMessage::DoBlob(blob))
127
+                    channel.send(WorkerMessage::DoBlob(Box::new(blob)))
128 128
                         .map_err(|e| format!("{}", e))?;
129 129
 
130 130
                 },
@@ -132,7 +132,7 @@ where P: AsRef<Path>,
132 132
                     return Err(format!("{}", err));
133 133
                 },
134 134
                 None => {
135
-                    chans[thread_id].send(WorkerMessage::PleaseStop)
135
+                    channel.send(WorkerMessage::PleaseStop)
136 136
                         .map_err(|e| format!("{}", e))?;
137 137
                     stopped_threads += 1;
138 138
                 },
@@ -152,7 +152,7 @@ where P: AsRef<Path>,
152 152
 
153 153
             match reader.next() {
154 154
                 Some(Ok(blob)) => {
155
-                    chans[thread_id].send(WorkerMessage::DoBlob(blob))
155
+                    chans[thread_id].send(WorkerMessage::DoBlob(Box::new(blob)))
156 156
                         .map_err(|e| format!("{}", e))?;
157 157
                 },
158 158
                 Some(Err(err)) => {