-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ares/spawn-reusable-thread to context and down the stack
This is done to workaround fibers issue: wingo/fibers#105 Fixes: https://todo.sr.ht/~abcdw/tickets/7
- Loading branch information
Showing
4 changed files
with
32 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
;;; guile-ares-rs --- Asynchronous Reliable Extensible Sleek RPC Server | ||
;;; | ||
;;; Copyright © 2023 Andrew Tropin <[email protected]> | ||
;;; Copyright © 2023, 2024 Andrew Tropin <[email protected]> | ||
;;; | ||
;;; This file is part of guile-ares-rs. | ||
;;; | ||
|
@@ -28,16 +28,18 @@ | |
#:use-module (srfi srfi-197) | ||
#:export (evaluation-extension)) | ||
|
||
(define (make-evaluation-supervisor session) | ||
(define (make-evaluation-supervisor session spawn-reusable-thread) | ||
(let ((control-channel (make-channel))) | ||
(spawn-fiber (evaluation-supervisor-thunk | ||
control-channel | ||
#:spawn-reusable-thread spawn-reusable-thread | ||
#:shutdown-condition (assoc-ref session 'shutdown-condition))) | ||
control-channel)) | ||
|
||
(define (create-evaluation-supervisor! session-atom) | ||
(define (create-evaluation-supervisor! session-atom spawn-reusable-thread) | ||
(let* ((tmp-evaluation-supervisor | ||
(make-evaluation-supervisor (atomic-box-ref session-atom))) | ||
(make-evaluation-supervisor (atomic-box-ref session-atom) | ||
spawn-reusable-thread)) | ||
(add-evaluation-supervisor | ||
(lambda (session) | ||
(let ((evaluation-supervisor | ||
|
@@ -54,22 +56,25 @@ | |
(evaluation-supervisor-shutdown tmp-evaluation-supervisor)) | ||
new-evaluation-supervisor)) | ||
|
||
(define (get-or-create-evaluation-supervisor! session-atom) | ||
(define (get-or-create-evaluation-supervisor! | ||
session-atom spawn-reusable-thread) | ||
(let ((evaluation-supervisor (assoc-ref (atomic-box-ref session-atom) | ||
'evaluation-supervisor))) | ||
(if evaluation-supervisor | ||
evaluation-supervisor | ||
(create-evaluation-supervisor! session-atom)))) | ||
(create-evaluation-supervisor! session-atom spawn-reusable-thread)))) | ||
|
||
(define (process-message context) | ||
(let* ((state (assoc-ref context 'nrepl/state)) | ||
(message (assoc-ref context 'nrepl/message)) | ||
(spawn-reusable-thread (assoc-ref context 'ares/spawn-reusable-thread)) | ||
(reply (assoc-ref context 'reply)) | ||
(session-id (assoc-ref message "session")) | ||
(session-atom (get-session state session-id))) | ||
(if session-id | ||
(evaluation-supervisor-process-nrepl-message | ||
(get-or-create-evaluation-supervisor! session-atom) | ||
(get-or-create-evaluation-supervisor! | ||
session-atom spawn-reusable-thread) | ||
message reply) | ||
(reply `(("status" . #("error" "no-session-id-provided" "done"))))))) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters