improve protection against multiple instantiation
original commit: bcbe42f4ffb06877d01846f7e6bf4d959db07a63
This commit is contained in:
parent
04d103943a
commit
b0f4d2f824
14
collects/mred/private/wx/common/once.rkt
Normal file
14
collects/mred/private/wx/common/once.rkt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#lang racket/base
|
||||||
|
(require ffi/unsafe)
|
||||||
|
|
||||||
|
(provide scheme_register_process_global)
|
||||||
|
|
||||||
|
;; This module must be instantiated only once:
|
||||||
|
|
||||||
|
(define scheme_register_process_global
|
||||||
|
(get-ffi-obj 'scheme_register_process_global #f (_fun _string _pointer -> _pointer)))
|
||||||
|
|
||||||
|
(let ([v (scheme_register_process_global "GRacket-support-initialized"
|
||||||
|
(cast 1 _scheme _pointer))])
|
||||||
|
(when v
|
||||||
|
(error "cannot instantiate `racket/gui/base' a second time in the same process")))
|
|
@ -5,7 +5,8 @@
|
||||||
racket/class
|
racket/class
|
||||||
"rbtree.rkt"
|
"rbtree.rkt"
|
||||||
"../../lock.rkt"
|
"../../lock.rkt"
|
||||||
"handlers.rkt")
|
"handlers.rkt"
|
||||||
|
"once.rkt")
|
||||||
|
|
||||||
(provide queue-evt
|
(provide queue-evt
|
||||||
set-check-queue!
|
set-check-queue!
|
||||||
|
@ -54,15 +55,6 @@
|
||||||
|
|
||||||
scheme_register_process_global)
|
scheme_register_process_global)
|
||||||
|
|
||||||
;; ------------------------------------------------------------
|
|
||||||
;; This module must be instantiated only once:
|
|
||||||
|
|
||||||
(define-mz scheme_register_process_global (_fun _string _pointer -> _pointer))
|
|
||||||
(let ([v (scheme_register_process_global "GRacket-support-initialized"
|
|
||||||
(cast 1 _scheme _pointer))])
|
|
||||||
(when v
|
|
||||||
(error "cannot start GRacket a second time in the same process")))
|
|
||||||
|
|
||||||
;; ------------------------------------------------------------
|
;; ------------------------------------------------------------
|
||||||
;; Create a Scheme evt that is ready when a queue is nonempty
|
;; Create a Scheme evt that is ready when a queue is nonempty
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require ffi/unsafe
|
(require ffi/unsafe
|
||||||
ffi/unsafe/define)
|
ffi/unsafe/define
|
||||||
|
"once.rkt")
|
||||||
|
|
||||||
(provide define-mz)
|
(provide define-mz)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user