aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIbrahim Mkusa <ibrahimmkusa@gmail.com>2017-04-09 15:19:57 -0400
committerIbrahim Mkusa <ibrahimmkusa@gmail.com>2017-04-09 15:19:57 -0400
commitba3f6821f5ef38b6e2e1990581765f80203817c9 (patch)
treed8e482d2d86d5fdb9bce001da1a30dc60873150c
parentf56f1cc46d738bc76820977af8c6a372f9702df4 (diff)
server.rkt is done, with exception of testing. Moving on to client.rkt
-rw-r--r--client.rkt2
-rw-r--r--server.rkt22
2 files changed, 18 insertions, 6 deletions
diff --git a/client.rkt b/client.rkt
index 70df4e6..f0d3578 100644
--- a/client.rkt
+++ b/client.rkt
@@ -12,6 +12,8 @@
;(define guard (make-custodian (current-custodian)))
;(current-custodian guard)
;; reads values continously from stdin and redisplays them
+
+;;;;;; NOT IN USE ;;;;;;;
(define (read-loop)
(display (read-line))
(display "\n")
diff --git a/server.rkt b/server.rkt
index c5bb6f3..5322a3d 100644
--- a/server.rkt
+++ b/server.rkt
@@ -22,11 +22,15 @@
(lambda ()
(semaphore-wait messages-s)
(semaphore-wait threads-s)
- (map (lambda (thread-descriptor)
- ()))))
-
-(define can-i-broadcast (make-semaphore 1))
-
+ (if (not (null? messages))
+ (begin (map (lambda (thread-descriptor)
+ (thread-send thread-descriptor (first messages))))
+ (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)
(accept-and-handle listener)
(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 ()
(displayln "\nGoodbye, shutting down all services\n")
(custodian-shutdown-all main-cust)))