diff options
author | Christopher Baines <mail@cbaines.net> | 2023-09-11 08:55:25 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2023-09-12 13:11:00 +0100 |
commit | 318f4072fadf984c287d35258048003f6f26aebd (patch) | |
tree | c1b47f5b717ed65c196f6072584cad8453c11b80 | |
parent | 500b14d65fe1a458aa34286572e1ddbf53249ddf (diff) | |
download | nar-herder-318f4072fadf984c287d35258048003f6f26aebd.tar nar-herder-318f4072fadf984c287d35258048003f6f26aebd.tar.gz |
Use fibers for the recent changes removal thread
-rw-r--r-- | nar-herder/recent-changes.scm | 18 | ||||
-rw-r--r-- | scripts/nar-herder.in | 18 |
2 files changed, 16 insertions, 20 deletions
diff --git a/nar-herder/recent-changes.scm b/nar-herder/recent-changes.scm index 79d41a6..ed3bd34 100644 --- a/nar-herder/recent-changes.scm +++ b/nar-herder/recent-changes.scm @@ -21,13 +21,14 @@ #:use-module (ice-9 threads) #:use-module ((guix build syscalls) #:select (set-thread-name)) + #:use-module (fibers) #:use-module (nar-herder database) - #:export (start-recent-change-removal-and-database-dump-thread)) + #:export (start-recent-change-removal-and-database-dump-fiber)) -(define (start-recent-change-removal-and-database-dump-thread database - database-dump-filename - check-interval - recent-changes-limit) +(define (start-recent-change-removal-and-database-dump-fiber database + database-dump-filename + check-interval + recent-changes-limit) (define (update-database-dump) (let ((temp-database-dump-filename (string-append database-dump-filename ".tmp"))) @@ -43,13 +44,8 @@ (simple-format (current-error-port) "updated database dump\n"))) - (call-with-new-thread + (spawn-fiber (lambda () - (catch 'system-error - (lambda () - (set-thread-name "nh recent change removal")) - (const #t)) - (while #t (with-exception-handler (lambda (exn) diff --git a/scripts/nar-herder.in b/scripts/nar-herder.in index e9d3150..0736592 100644 --- a/scripts/nar-herder.in +++ b/scripts/nar-herder.in @@ -610,15 +610,6 @@ (log-msg 'INFO "dumping database...") (dump-database database (assq-ref opts 'database-dump)))) - (start-recent-change-removal-and-database-dump-thread - database - (let ((filename (assq-ref opts 'database-dump))) - (if (string=? filename "disabled") - #f - filename)) - (* 24 3600) ; 24 hours - (assq-ref opts 'recent-changes-limit)) - (let ((finished? (make-condition))) (call-with-new-thread (lambda () @@ -629,6 +620,15 @@ (run-fibers (lambda () + (start-recent-change-removal-and-database-dump-fiber + database + (let ((filename (assq-ref opts 'database-dump))) + (if (string=? filename "disabled") + #f + filename)) + (* 24 3600) ; 24 hours + (assq-ref opts 'recent-changes-limit)) + (and=> (assq-ref opts 'mirror) (lambda (mirror) (start-fetch-changes-fiber database |