#lang racket/base
(require "mzrt-sema.rkt"
"horrible-pointer-hack.rkt"
ffi/unsafe racket/place)
(provide mzrt-sema-listener)
(define (mzrt-sema-listener mzrt-sema)
(define pre (current-inexact-milliseconds))
(define p
(place
ch
(define mzrt-sema
(cast (num->pointer (place-channel-get ch))
_pointer
_mzrt-semaphore))
(place-channel-put ch 'ready)
(let loop ()
(mzrt-sema-wait mzrt-sema)
(place-channel-put ch 'signal)
(loop))))
(place-channel-put p (pointer->num mzrt-sema))
(define up (place-channel-get p))
(unless (eq? up 'ready)
(error 'mzrt-sema-listener "failed to initialize place correctly"))
(define post (current-inexact-milliseconds))
(printf "startup time: ~s\n" (- post pre))
p)