server.rkt is done, with exception of testing. Moving on to client.rkt
This commit is contained in:
parent
f56f1cc46d
commit
ba3f6821f5
@ -12,6 +12,8 @@
|
|||||||
;(define guard (make-custodian (current-custodian)))
|
;(define guard (make-custodian (current-custodian)))
|
||||||
;(current-custodian guard)
|
;(current-custodian guard)
|
||||||
;; reads values continously from stdin and redisplays them
|
;; reads values continously from stdin and redisplays them
|
||||||
|
|
||||||
|
;;;;;; NOT IN USE ;;;;;;;
|
||||||
(define (read-loop)
|
(define (read-loop)
|
||||||
(display (read-line))
|
(display (read-line))
|
||||||
(display "\n")
|
(display "\n")
|
||||||
|
22
server.rkt
22
server.rkt
@ -22,11 +22,15 @@
|
|||||||
(lambda ()
|
(lambda ()
|
||||||
(semaphore-wait messages-s)
|
(semaphore-wait messages-s)
|
||||||
(semaphore-wait threads-s)
|
(semaphore-wait threads-s)
|
||||||
(map (lambda (thread-descriptor)
|
(if (not (null? messages))
|
||||||
()))))
|
(begin (map (lambda (thread-descriptor)
|
||||||
|
(thread-send thread-descriptor (first messages))))
|
||||||
(define can-i-broadcast (make-semaphore 1))
|
(set! messages (rest messages))
|
||||||
|
)
|
||||||
|
(display "No message to display\n") ; for later create file port for errors and save error messages to that file
|
||||||
|
)
|
||||||
|
(semaphore-post threads-s)
|
||||||
|
(semaphore-post messages-s)))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -44,7 +48,13 @@
|
|||||||
(define (loop)
|
(define (loop)
|
||||||
(accept-and-handle listener)
|
(accept-and-handle listener)
|
||||||
(loop))
|
(loop))
|
||||||
(thread loop))
|
(thread loop)
|
||||||
|
;; Create a thread whose job is to simply call broadcast iteratively
|
||||||
|
(thread (lambda ()
|
||||||
|
(let loopb []
|
||||||
|
broadcast
|
||||||
|
(sleep 10) ;; sleep for 10 seconds between broadcasts
|
||||||
|
(loopb)))))
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(displayln "\nGoodbye, shutting down all services\n")
|
(displayln "\nGoodbye, shutting down all services\n")
|
||||||
(custodian-shutdown-all main-cust)))
|
(custodian-shutdown-all main-cust)))
|
||||||
|
Loading…
Reference in New Issue
Block a user