File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -260,7 +260,7 @@ A kernel will not be garbage collected until `end-kernel' is called."
260
260
(fill-workers workers kernel)
261
261
kernel))
262
262
263
- (defun check-kernel ()
263
+ (defun check-kernel (&key worker-count )
264
264
" Ensures the value of `*kernel*' is a kernel instance. Provides the
265
265
MAKE-KERNEL and STORE-VALUE restarts. Returns `*kernel*'."
266
266
(or *kernel*
@@ -275,6 +275,16 @@ MAKE-KERNEL and STORE-VALUE restarts. Returns `*kernel*'."
275
275
(check-type value kernel)
276
276
(setf *kernel* value)))))
277
277
278
+ (defun ensure-kernel (worker-count &rest other-keys)
279
+ " Return `*kernel*', a kernel instance featuring WORKER-COUNT."
280
+ ; ; Notice that when *kernel* exists with 2 workers, then calling:
281
+ ; ; (ensure-kernel N :name "a-different-name-from-*kernel*")
282
+ ; ; has no effect since the number of workers match.
283
+ (if (and *kernel*
284
+ (eq (length (workers *kernel* )) worker-count))
285
+ *kernel*
286
+ (setf *kernel* (apply #' make-kernel worker-count other-keys))))
287
+
278
288
(defmacro define-worker-info-reader (name slot &optional (result slot))
279
289
` (defun , name ()
280
290
, (format nil " Return the ~a passed to `make-kernel'."
Original file line number Diff line number Diff line change 42
42
#+ lparallel.with-stealing-scheduler # :lparallel.spin-queue)
43
43
(:export # :make-kernel
44
44
# :check-kernel
45
+ # :ensure-kernel
45
46
# :end-kernel
46
47
# :kernel-worker-count
47
48
# :kernel-worker-index
You can’t perform that action at this time.
0 commit comments