@@ -226,7 +226,9 @@ impl Queue {
226
226
/// Submit a function for asynchronous execution on the [Queue].
227
227
pub fn exec_async < F > ( & self , work : F )
228
228
where
229
- F : Send + FnOnce ( ) ,
229
+ // We need `'static` to make sure any referenced values are borrowed for
230
+ // long enough since `work` will be performed asynchronously.
231
+ F : Send + FnOnce ( ) + ' static ,
230
232
{
231
233
let work_boxed = Box :: into_raw ( Box :: new ( work) ) . cast ( ) ;
232
234
@@ -254,7 +256,9 @@ impl Queue {
254
256
/// Enqueue a barrier function for asynchronous execution on the [Queue] and return immediately.
255
257
pub fn barrier_async < F > ( & self , work : F )
256
258
where
257
- F : Send + FnOnce ( ) ,
259
+ // We need `'static` to make sure any referenced values are borrowed for
260
+ // long enough since `work` will be performed asynchronously.
261
+ F : Send + FnOnce ( ) + ' static ,
258
262
{
259
263
let work_boxed = Box :: into_raw ( Box :: new ( work) ) . cast ( ) ;
260
264
@@ -276,7 +280,9 @@ impl Queue {
276
280
/// Submit a function for synchronous execution and mark the function as a barrier for subsequent concurrent tasks.
277
281
pub fn barrier_async_and_wait < F > ( & self , work : F )
278
282
where
279
- F : Send + FnOnce ( ) ,
283
+ // We need `'static` to make sure any referenced values are borrowed for
284
+ // long enough since `work` will be performed asynchronously.
285
+ F : Send + FnOnce ( ) + ' static ,
280
286
{
281
287
let work_boxed = Box :: into_raw ( Box :: new ( work) ) . cast ( ) ;
282
288
0 commit comments