crossfire/agent-deployment/crossfire-agent.rkt

23 lines
912 B
Racket
Raw Normal View History

2020-12-13 01:28:15 +00:00
#lang racket/base
;; this is necessary because our C embedding runtime doesn't flush the plumber by default
;; idk how to do it in C, therefore we do it in racket, just before exiting
;; we need to flush otherwise logs might get dropped, particularly those relating to the error
(define old-esc-handler (error-escape-handler))
(error-escape-handler (lambda ()
(plumber-flush-all (current-plumber))
(old-esc-handler)))
;; execute agent-main
; (require "../crossfire/agent.rkt")
; (agent-main)
(require "../crossfire/static-support.rkt")
(require ffi/unsafe)
(define _rktio (_cpointer 'rktio))
(define rktio-inst (get-ffi-obj/static "scheme_rktio" _rktio))
(define rktio-call (get-ffi-obj/static "rktio_processor_count" (_fun _rktio -> _int)))
(printf "num cpus: ~a\n" (rktio-call rktio-inst))
;; and if no error, also flush
(plumber-flush-all (current-plumber))