original commit: 0f2e555ddb2fe756a3f2925eb6d2616cb1c10511
This commit is contained in:
Robby Findler 2003-11-24 17:55:29 +00:00
parent 5f51aca45a
commit 2e0e0a86b4
2 changed files with 7 additions and 16 deletions

View File

@ -147,7 +147,7 @@
"preference in that file is used instead of \\var{value}."
""
"Once"
"@flink preferences:start-writing-thread "
"@flink preferences:start-writing-timer "
"has been called, no more default preferences may be registered.")
(preferences:set-un/marshall
(symbol? (any? . -> . printable?) (printable? . -> . any?) . -> . void?)
@ -188,7 +188,7 @@
()
"\\rawscm{(preferences:restore-defaults)} restores the users's configuration to the"
"default preferences.")
(preferences:start-writing-thread
(preferences:start-writing-timer
(-> void?)
()
"Starts a thread that periodically flushes the preferences"

View File

@ -61,20 +61,11 @@
(hash-table-put! changed p #t))
;; periodically checks to see if changes need to be written out.
(define (start-writing-thread)
(define (start-writing-timer)
(set! no-more-defaults? #t)
(thread
(lambda ()
(let loop ()
(sleep 5)
(let ([s (make-semaphore 0)])
(queue-callback
(lambda ()
(maybe-flush-changes)
(semaphore-post s))
#f)
(semaphore-wait s))
(loop))))
(new timer%
[notify-callback (lambda () (maybe-flush-changes))]
[interval (* 5 1000)])
(void))
(define last-time-read #f)
@ -235,7 +226,7 @@
;; set-default : (sym TST (TST -> boolean) -> void
(define (set-default p default-value checker)
(when no-more-defaults?
(error 'set-default "tried to register the pref ~e too late; preferences:start-writing-thread has already been called" p))
(error 'set-default "tried to register the pref ~e too late; preferences:start-writing-timer has already been called" p))
(let ([default-okay? (checker default-value)])
(unless default-okay?
(error 'set-default "~s: checker (~s) returns ~s for ~s, expected #t~n"