Add `phpinspect-pipeline-pause-time'
ci/woodpecker/push/woodpecker Pipeline failed Details

WIP-cache
Hugo Thunnissen 10 months ago
parent ea7795c76e
commit 94d5b75455

@ -61,7 +61,6 @@
:documentation
"The directories that this autoloader finds code in."))
(cl-defstruct (phpinspect-autoloader
(:constructor phpinspect-make-autoloader))
(project nil
@ -167,9 +166,6 @@ bareword typenames."))
(push type-fqn bag)
(puthash type-name bag (phpinspect-autoloader-type-name-fqn-bags al)))))
(phpinspect-define-pipeline-step phpinspect-al-strategy-execute phpinspect-al-strategy-execute)
(cl-defmethod phpinspect-iterate-composer-jsons
((al phpinspect-autoloader) file)
(let* ((fs (phpinspect-project-fs (phpinspect-autoloader-project al)))
@ -216,14 +212,18 @@ bareword typenames."))
autoload)
(phpinspect-pipeline-emit-all batch))))
(phpinspect-define-pipeline-step phpinspect-iterate-composer-jsons
phpinspect-iterate-composer-jsons)
(cl-defmethod phpinspect-autoloader-resolve ((autoloader phpinspect-autoloader)
typename-symbol)
(or (gethash typename-symbol (phpinspect-autoloader-own-types autoloader))
(gethash typename-symbol (phpinspect-autoloader-types autoloader))))
(phpinspect-define-pipeline-step phpinspect-iterate-composer-jsons
phpinspect-iterate-composer-jsons)
(phpinspect-define-pipeline-step phpinspect-al-strategy-execute
phpinspect-al-strategy-execute)
(cl-defmethod phpinspect-autoloader-refresh ((autoloader phpinspect-autoloader) &optional async-callback)
"Refresh autoload definitions by reading composer.json files
from the project and vendor folders."
@ -242,10 +242,11 @@ bareword typenames."))
(lambda (_result error)
(if error
(message "Error during autoloader refresh: %s" error)
(message (concat "Refreshed project autoloader. Found %d types within project,"
" %d types total.")
(hash-table-count (phpinspect-autoloader-own-types autoloader))
(hash-table-count (phpinspect-autoloader-types autoloader))))))
(message
(concat "Refreshed project autoloader. Found %d types within project,"
" %d types total.")
(hash-table-count (phpinspect-autoloader-own-types autoloader))
(hash-table-count (phpinspect-autoloader-types autoloader))))))
:into (phpinspect-iterate-composer-jsons :with-context autoloader)
:into phpinspect-al-strategy-execute)))

@ -28,6 +28,10 @@
(define-error 'phpinspect-pipeline-incoming "Signal for incoming pipeline data")
(define-error 'phpinspect-pipeline-error "Signal for pipeline errors")
(defvar phpinspect-pipeline-pause-time 0.5
"Number of seconds to pause a pipeline thread when emacs receives
user input.")
(cl-defstruct (phpinspect-pipeline-end (:constructor phpinspect-make-pipeline-end))
(value nil
:type any)
@ -90,7 +94,6 @@
(when errors
(signal 'phpinspect-pipeline-error errors))))
(define-inline phpinspect-pipeline-emit (data)
(inline-letevals (data)
(inline-quote
@ -117,7 +120,8 @@
(inline-quote
(if (input-pending-p)
(let ((mx (make-mutex)))
(phpinspect-thread-pause 1 mx (make-condition-variable mx "phpinspect-pipeline-pause")))
(phpinspect-thread-pause
phpinspect-pipeline-pause-time mx (make-condition-variable mx "phpinspect-pipeline-pause")))
(thread-yield))))
(defun phpinspect--chain-pipeline-steps (steps start-queue end-queue ctx)
@ -262,7 +266,6 @@
"phpinspect-pipeline-async")
,(append '(phpinspect--pipeline) (list seed-form) macro-params)))))
(define-inline phpinspect-pipeline-receive (queue)
(inline-letevals (queue)
(inline-quote

@ -187,5 +187,19 @@ context for completion."
(json-key-type 'string))
,@body))
(defun phpinspect-thread-pause (pause-time mx continue)
"Pause current thread using MX and CONTINUE for PAUSE-TIME idle seconds.
PAUSE-TIME must be the idle time that the thread should pause for.
MX must be a mutex
CONTINUE must be a condition-variable"
(phpinspect--log "Thread '%s' is paused for %d seconds" (thread-name (current-thread)) pause-time)
(run-with-idle-timer
pause-time
nil
(lambda () (with-mutex mx (condition-notify continue))))
(with-mutex mx (condition-wait continue))
(phpinspect--log "Thread '%s' continuing execution" (thread-name (current-thread))))
(provide 'phpinspect-util)
;;; phpinspect-util.el ends here

@ -24,6 +24,7 @@
;;; Code:
(require 'cl-lib)
(require 'phpinspect-util)
(require 'phpinspect-project)
(require 'phpinspect-index)
(require 'phpinspect-class)
@ -115,21 +116,6 @@ already present in the queue."
(cl-defmethod phpinspect-worker-enqueue ((worker phpinspect-dynamic-worker) task)
(phpinspect-worker-enqueue (phpinspect-resolve-dynamic-worker worker)
task))
(defun phpinspect-thread-pause (pause-time mx continue)
"Pause current thread using MX and CONTINUE for PAUSE-TIME idle seconds.
PAUSE-TIME must be the idle time that the thread should pause for.
MX must be a mutex
CONTINUE must be a condition-variable"
(phpinspect--log "Thread '%s' is paused for %d seconds" (thread-name (current-thread)) pause-time)
(run-with-idle-timer
pause-time
nil
(lambda () (with-mutex mx (condition-notify continue))))
(with-mutex mx (condition-wait continue))
(phpinspect--log "Index thread continuing"))
(cl-defgeneric phpinspect-worker-make-thread-function (worker)
"Create a function that can be used to start WORKER's thread.")

Loading…
Cancel
Save