@@ -108,26 +108,10 @@ impl<Context: Clone + Send + UnwindSafe + 'static> Runner<Context> {
108
108
}
109
109
110
110
fn run_single_job ( & self , sender : SyncSender < Event > ) {
111
+ use diesel:: result:: Error :: RollbackTransaction ;
112
+
111
113
let job_registry = AssertUnwindSafe ( self . job_registry . clone ( ) ) ;
112
114
let environment = self . environment . clone ( ) ;
113
- self . get_single_job ( sender, move |job, state| {
114
- let job_registry = job_registry. read ( ) ;
115
- let run_task_fn = job_registry
116
- . get ( & job. job_type )
117
- . ok_or_else ( || PerformError :: from ( format ! ( "Unknown job type {}" , job. job_type) ) ) ?;
118
-
119
- run_task_fn ( environment, state, job. data )
120
- } )
121
- }
122
-
123
- fn get_single_job < F > ( & self , sender : SyncSender < Event > , f : F )
124
- where
125
- F : FnOnce ( storage:: BackgroundJob , PerformState < ' _ > ) -> Result < ( ) , PerformError >
126
- + Send
127
- + UnwindSafe
128
- + ' static ,
129
- {
130
- use diesel:: result:: Error :: RollbackTransaction ;
131
115
132
116
// The connection may not be `Send` so we need to clone the pool instead
133
117
let pool = self . connection_pool . clone ( ) ;
@@ -175,7 +159,17 @@ impl<Context: Clone + Send + UnwindSafe + 'static> Runner<Context> {
175
159
catch_unwind ( || {
176
160
// Ensure the whole `AssertUnwindSafe(_)` is moved
177
161
let state = state;
178
- f ( job, state. 0 )
162
+
163
+ let job_registry = job_registry. read ( ) ;
164
+ let run_task_fn =
165
+ job_registry. get ( & job. job_type ) . ok_or_else ( || {
166
+ PerformError :: from ( format ! (
167
+ "Unknown job type {}" ,
168
+ job. job_type
169
+ ) )
170
+ } ) ?;
171
+
172
+ run_task_fn ( environment, state. 0 , job. data )
179
173
} )
180
174
. map_err ( |e| try_to_extract_panic_info ( & e) )
181
175
} )
0 commit comments