Fix job tests
This commit is contained in:
parent
856de304fb
commit
94a4243a84
5 changed files with 15 additions and 27 deletions
|
|
@ -6,7 +6,7 @@
|
|||
(uiop:define-package :stoe/core/containers
|
||||
(:use :cl :stoe/core/utils :stoe/core/thread)
|
||||
(:export #:queue #:stack #:make-queue #:make-stack
|
||||
#:enqueue #:dequeue #:push-stack #:pop-stack #:peek
|
||||
#:enqueue #:dequeue #:push-stack #:pop-stack #:peek #:size
|
||||
#:safe-queue #:safe-stack
|
||||
#:make-safe-queue #:make-safe-stack))
|
||||
(in-package :stoe/core/containers)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
(setf thread-id 0)))
|
||||
|
||||
(defun job-thread-available-p ()
|
||||
(> *job-thread-count* 0))
|
||||
(> (reduce #'+ (mapcar (lambda (x) (if (typep x 'job-thread) 1 0)) *thread-list*)) 0))
|
||||
|
||||
(defun make-job (id fun args callback errback)
|
||||
(make-instance 'job :id id :fun fun :args args :callback callback :errback errback))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
(uiop:define-package :stoe/test/all
|
||||
(:nicknames :test)
|
||||
(:use-reexport
|
||||
;; :stoe/test/job-utils
|
||||
;; :stoe/test/jobs
|
||||
:stoe/test/jobs
|
||||
;; :stoe/test/resources
|
||||
:stoe/test/entity))
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
#|
|
||||
This file is a part of stoe project.
|
||||
Copyright (c) 2015 Renaud Casenave-Péré (renaud@casenave-pere.fr)
|
||||
|#
|
||||
|
||||
(uiop:define-package :stoe/test/job-utils
|
||||
(:use :cl :prove
|
||||
:stoe/core/jobs)
|
||||
(:export #:with-new-job-thread))
|
||||
(in-package :stoe/test/job-utils)
|
||||
|
||||
(defmacro with-new-job-thread (count &body body)
|
||||
`(progn
|
||||
(dotimes (i ,count)
|
||||
(push-new-job-thread (format nil "Test thread ~d" i)))
|
||||
,@body
|
||||
(mapc (lambda (thread) (terminate-thread thread))
|
||||
stoe/core/jobs::*thread-list*)
|
||||
(sleep 0.5)
|
||||
(stoe/core/jobs::update 0)))
|
||||
|
|
@ -7,15 +7,24 @@
|
|||
(:use :cl :prove
|
||||
:stoe/core/containers
|
||||
:stoe/core/thread
|
||||
:stoe/core/jobs
|
||||
:stoe/test/job-utils))
|
||||
:stoe/core/jobs))
|
||||
(in-package :stoe/test/jobs)
|
||||
|
||||
(stoe/core/jobs::initialize)
|
||||
|
||||
(defmacro with-new-job-thread (count &body body)
|
||||
`(progn
|
||||
(dotimes (i ,count)
|
||||
(push-new-job-thread (format nil "Test thread ~d" i)))
|
||||
,@body
|
||||
(mapc (lambda (thread) (terminate-thread thread))
|
||||
stoe/core/jobs::*thread-list*)
|
||||
(sleep 0.5)
|
||||
(stoe/core/jobs::update 0)))
|
||||
|
||||
(defun counter (x)
|
||||
(dotimes (i 10 x)
|
||||
(format t "x ~a~%" x)
|
||||
(format t "~a~%" x)
|
||||
(incf x)))
|
||||
|
||||
(plan 3)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue