thread & io: code clean-ups
Remove unused `require`s and fix some indentation.
This commit is contained in:
parent
82b5ec8d18
commit
dffcbc1cb2
|
@ -433,14 +433,14 @@
|
||||||
(or stderr-logging-arg
|
(or stderr-logging-arg
|
||||||
(let ([spec (getenv "PLTSTDERR")])
|
(let ([spec (getenv "PLTSTDERR")])
|
||||||
(if spec
|
(if spec
|
||||||
(parse-logging-spec spec "in PLTSTDERR environment variable" #f)
|
(parse-logging-spec "stderr" spec "in PLTSTDERR environment variable" #f)
|
||||||
'(error)))))
|
'(error)))))
|
||||||
|
|
||||||
(define stdout-logging
|
(define stdout-logging
|
||||||
(or stdout-logging-arg
|
(or stdout-logging-arg
|
||||||
(let ([spec (getenv "PLTSTDOUT")])
|
(let ([spec (getenv "PLTSTDOUT")])
|
||||||
(if spec
|
(if spec
|
||||||
(parse-logging-spec spec "in PLTSTDOUT environment variable" #f)
|
(parse-logging-spec "stdout" spec "in PLTSTDOUT environment variable" #f)
|
||||||
'()))))
|
'()))))
|
||||||
|
|
||||||
(when (getenv "PLT_STATS_ON_BREAK")
|
(when (getenv "PLT_STATS_ON_BREAK")
|
||||||
|
|
|
@ -13,21 +13,21 @@
|
||||||
->path)
|
->path)
|
||||||
|
|
||||||
(struct path (bytes convention)
|
(struct path (bytes convention)
|
||||||
#:property prop:custom-write
|
#:property prop:custom-write
|
||||||
(lambda (p port mode)
|
(lambda (p port mode)
|
||||||
(when mode
|
(when mode
|
||||||
(write-string "#<path:" port))
|
(write-string "#<path:" port))
|
||||||
(write-string (bytes->string/locale (path-bytes p)) port)
|
(write-string (bytes->string/locale (path-bytes p)) port)
|
||||||
(when mode
|
(when mode
|
||||||
(write-string ">" port)))
|
(write-string ">" port)))
|
||||||
#:property prop:equal+hash
|
#:property prop:equal+hash
|
||||||
(list
|
(list
|
||||||
(lambda (p1 p2 eql?)
|
(lambda (p1 p2 eql?)
|
||||||
(eql? (path-bytes p1) (path-bytes p2)))
|
(eql? (path-bytes p1) (path-bytes p2)))
|
||||||
(lambda (p hc)
|
(lambda (p hc)
|
||||||
(hc (path-bytes p)))
|
(hc (path-bytes p)))
|
||||||
(lambda (p hc)
|
(lambda (p hc)
|
||||||
(hc (path-bytes p)))))
|
(hc (path-bytes p)))))
|
||||||
|
|
||||||
(define is-path?
|
(define is-path?
|
||||||
(let ([path? (lambda (p)
|
(let ([path? (lambda (p)
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require "../common/check.rkt"
|
(require "../common/check.rkt"
|
||||||
"../host/thread.rkt"
|
|
||||||
"parameter.rkt"
|
"parameter.rkt"
|
||||||
"read-and-peek.rkt"
|
"read-and-peek.rkt"
|
||||||
"input-port.rkt"
|
"input-port.rkt"
|
||||||
"count.rkt"
|
|
||||||
"progress-evt.rkt"
|
"progress-evt.rkt"
|
||||||
"flush-output.rkt")
|
"flush-output.rkt")
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,9 @@
|
||||||
(require "../common/check.rkt"
|
(require "../common/check.rkt"
|
||||||
"../host/thread.rkt"
|
"../host/thread.rkt"
|
||||||
"input-port.rkt"
|
"input-port.rkt"
|
||||||
"output-port.rkt"
|
|
||||||
"custom-port.rkt"
|
"custom-port.rkt"
|
||||||
"pipe.rkt"
|
"pipe.rkt"
|
||||||
"peek-via-read-port.rkt"
|
"peek-via-read-port.rkt")
|
||||||
"buffer-mode.rkt")
|
|
||||||
|
|
||||||
(provide make-input-port)
|
(provide make-input-port)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
"../host/thread.rkt"
|
"../host/thread.rkt"
|
||||||
"parameter.rkt"
|
"parameter.rkt"
|
||||||
"read-and-peek.rkt"
|
"read-and-peek.rkt"
|
||||||
"port.rkt"
|
|
||||||
"input-port.rkt"
|
"input-port.rkt"
|
||||||
(submod "bytes-input.rkt" internal)
|
(submod "bytes-input.rkt" internal)
|
||||||
"../string/utf-8-decode.rkt"
|
"../string/utf-8-decode.rkt"
|
||||||
|
|
|
@ -26,20 +26,20 @@
|
||||||
|
|
||||||
(struct channel (get-queue
|
(struct channel (get-queue
|
||||||
put-queue)
|
put-queue)
|
||||||
#:property
|
#:property
|
||||||
prop:evt
|
prop:evt
|
||||||
(poller (lambda (ch poll-ctx)
|
(poller (lambda (ch poll-ctx)
|
||||||
(channel-get/poll ch poll-ctx))))
|
(channel-get/poll ch poll-ctx))))
|
||||||
|
|
||||||
(struct channel-put-evt* (ch v)
|
(struct channel-put-evt* (ch v)
|
||||||
#:property
|
#:property
|
||||||
prop:evt
|
prop:evt
|
||||||
(poller (lambda (cp poll-ctx)
|
(poller (lambda (cp poll-ctx)
|
||||||
(channel-put/poll (channel-put-evt*-ch cp)
|
(channel-put/poll (channel-put-evt*-ch cp)
|
||||||
(channel-put-evt*-v cp)
|
(channel-put-evt*-v cp)
|
||||||
cp
|
cp
|
||||||
poll-ctx)))
|
poll-ctx)))
|
||||||
#:reflection-name 'channel-put-evt)
|
#:reflection-name 'channel-put-evt)
|
||||||
|
|
||||||
;; A channel must not match get and put from the same thread, which is
|
;; A channel must not match get and put from the same thread, which is
|
||||||
;; a danger when `sync` queues up multiple events at a time:
|
;; a danger when `sync` queues up multiple events at a time:
|
||||||
|
@ -209,6 +209,7 @@
|
||||||
(define (set-sync-on-channel! sync)
|
(define (set-sync-on-channel! sync)
|
||||||
(set! sync-on-channel sync))
|
(set! sync-on-channel sync))
|
||||||
|
|
||||||
;;
|
;; ----------------------------------------
|
||||||
|
|
||||||
(define-values (impersonator-prop:channel-put channel-put-impersonator? channel-put-impersonator-ref)
|
(define-values (impersonator-prop:channel-put channel-put-impersonator? channel-put-impersonator-ref)
|
||||||
(make-impersonator-property 'channel-put-impersonator))
|
(make-impersonator-property 'channel-put-impersonator))
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require racket/unsafe/ops
|
(require "atomic.rkt")
|
||||||
"atomic.rkt")
|
|
||||||
|
|
||||||
(provide prop:evt
|
(provide prop:evt
|
||||||
evt?
|
evt?
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
(struct plumber (callbacks ; hash table of handles -> callbacks
|
(struct plumber (callbacks ; hash table of handles -> callbacks
|
||||||
weak-callbacks) ; same, but weak references
|
weak-callbacks) ; same, but weak references
|
||||||
#:property prop:authentic #t)
|
#:authentic)
|
||||||
|
|
||||||
(define (make-plumber)
|
(define (make-plumber)
|
||||||
(plumber (make-hasheq)
|
(plumber (make-hasheq)
|
||||||
|
|
|
@ -24,19 +24,19 @@
|
||||||
|
|
||||||
(struct semaphore ([count #:mutable]
|
(struct semaphore ([count #:mutable]
|
||||||
queue)
|
queue)
|
||||||
#:property
|
#:property
|
||||||
prop:evt
|
prop:evt
|
||||||
(poller (lambda (s poll-ctx)
|
(poller (lambda (s poll-ctx)
|
||||||
(semaphore-wait/poll s poll-ctx))))
|
(semaphore-wait/poll s poll-ctx))))
|
||||||
|
|
||||||
(struct semaphore-peek-evt (sema)
|
(struct semaphore-peek-evt (sema)
|
||||||
#:property
|
#:property
|
||||||
prop:evt
|
prop:evt
|
||||||
(poller (lambda (sp poll-ctx)
|
(poller (lambda (sp poll-ctx)
|
||||||
(semaphore-wait/poll (semaphore-peek-evt-sema sp)
|
(semaphore-wait/poll (semaphore-peek-evt-sema sp)
|
||||||
poll-ctx
|
poll-ctx
|
||||||
#:peek? #t
|
#:peek? #t
|
||||||
#:result sp))))
|
#:result sp))))
|
||||||
|
|
||||||
(struct semaphore-peek-select-waiter select-waiter ())
|
(struct semaphore-peek-select-waiter select-waiter ())
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
(submod "channel.rkt" for-sync)
|
(submod "channel.rkt" for-sync)
|
||||||
"thread.rkt"
|
"thread.rkt"
|
||||||
(only-in (submod "thread.rkt" scheduling)
|
(only-in (submod "thread.rkt" scheduling)
|
||||||
current-break-enabled-cell
|
|
||||||
thread-descheduled?)
|
thread-descheduled?)
|
||||||
"schedule-info.rkt")
|
"schedule-info.rkt")
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require "evt.rkt"
|
(require "evt.rkt"
|
||||||
"semaphore.rkt"
|
"semaphore.rkt")
|
||||||
"internal-error.rkt")
|
|
||||||
|
|
||||||
(provide (rename-out [get-system-idle-evt system-idle-evt])
|
(provide (rename-out [get-system-idle-evt system-idle-evt])
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require "engine.rkt"
|
(require "check.rkt"
|
||||||
"check.rkt"
|
|
||||||
"internal-error.rkt"
|
"internal-error.rkt"
|
||||||
"atomic.rkt")
|
"atomic.rkt")
|
||||||
|
|
||||||
|
|
|
@ -117,12 +117,12 @@
|
||||||
[cpu-time #:mutable] ; accumulates CPU time in milliseconds
|
[cpu-time #:mutable] ; accumulates CPU time in milliseconds
|
||||||
|
|
||||||
[condition-wakeup #:mutable])
|
[condition-wakeup #:mutable])
|
||||||
#:property prop:waiter
|
#:property prop:waiter
|
||||||
(make-waiter-methods
|
(make-waiter-methods
|
||||||
#:suspend! (lambda (t i-cb r-cb) (thread-deschedule! t #f i-cb r-cb))
|
#:suspend! (lambda (t i-cb r-cb) (thread-deschedule! t #f i-cb r-cb))
|
||||||
#:resume! (lambda (t v) (thread-reschedule! t) v))
|
#:resume! (lambda (t v) (thread-reschedule! t) v))
|
||||||
#:property prop:evt (lambda (t) (wrap-evt (get-thread-dead-evt t)
|
#:property prop:evt (lambda (t) (wrap-evt (get-thread-dead-evt t)
|
||||||
(lambda (v) t))))
|
(lambda (v) t))))
|
||||||
|
|
||||||
(define root-thread #f)
|
(define root-thread #f)
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
;; Used for semaphores and channels to run a "just selected" callback
|
;; Used for semaphores and channels to run a "just selected" callback
|
||||||
;; when synchronized:
|
;; when synchronized:
|
||||||
(struct select-waiter (proc)
|
(struct select-waiter (proc)
|
||||||
#:property prop:waiter
|
#:property prop:waiter
|
||||||
(make-waiter-methods #:suspend! (lambda args (internal-error "should not suspend a select-waiter"))
|
(make-waiter-methods #:suspend! (lambda args (internal-error "should not suspend a select-waiter"))
|
||||||
#:resume! (lambda (w s)
|
#:resume! (lambda (w s)
|
||||||
((select-waiter-proc w)))))
|
((select-waiter-proc w)))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user