<html><body><div style="color:#000; background-color:#fff; font-family:garamond, new york, times, serif;font-size:12pt"><div><span>Why did you choose to port it to OpenBSD?</span></div><div><br></div>  <div style="font-family: garamond, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <hr size="1">  <font face="Arial" size="2"> <b><span style="font-weight:bold;">From:</span></b> "Petersen, Chris" <CPetersen@cw.bc.ca><br> <b><span style="font-weight: bold;">To:</span></b> tcl super dude <tcleval@gmail.com>; "gambit-list@iro.umontreal.ca" <gambit-list@iro.umontreal.ca> <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, September 2, 2013 8:54 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [gambit-list] lambdanative and remote repl<br> </font> </div> <div class="y_msg_container"><br><br>Thanks for reporting this.
 The gui eventloop was preempting gambit threads on linux and openbsd. I could not reproduce the problem on other platforms. Fixed in lambdanative commit 0db18463.<br><br>In general, if you want to implement a multi-threaded server, you'd be better off working from a non-gui application like DemoConsole, to avoid the rendering overhead. This would essentially be equivalent to generating an executable directly with gsc.<br><br>btw please use the lambdanative issue reporting tool on github for bugs/issues specific to lambdanative, as that will help us track and coordinate fixes better.<br><br>Chris <br> <br><br>________________________________________<br>From: <a ymailto="mailto:gambit-list-bounces@iro.umontreal.ca" href="mailto:gambit-list-bounces@iro.umontreal.ca">gambit-list-bounces@iro.umontreal.ca</a> [<a ymailto="mailto:gambit-list-bounces@iro.umontreal.ca" href="mailto:gambit-list-bounces@iro.umontreal.ca">gambit-list-bounces@iro.umontreal.ca</a>]
 On Behalf Of tcl super dude [<a ymailto="mailto:tcleval@gmail.com" href="mailto:tcleval@gmail.com">tcleval@gmail.com</a>]<br>Sent: Sunday, September 01, 2013 9:44 PM<br>To: <a ymailto="mailto:gambit-list@iro.umontreal.ca" href="mailto:gambit-list@iro.umontreal.ca">gambit-list@iro.umontreal.ca</a><br>Subject: [gambit-list] lambdanative and remote repl<br><br>Hi,<br><br>I started a remote repl with the demoredsquare app but the repl get too slow, somehow the app takes forever to process the repl events<br><br>main.scm:<br><br>(include "repl.scm")<br><br>(define gui #f)<br><br>(start-repl-server)<br>(main<br>;; initialization<br>  (lambda (w h)<br>    (make-window 320 480)<br>    (glgui-orientation-set! GUI_PORTRAIT)<br>    (set! gui (make-glgui))<br>    (let* ((w (glgui-width-get))<br>           (h (glgui-height-get))<br>           (dim (min (/ w 2) (/ h
 2))))<br>      (glgui-box gui (/ (- w dim) 2) (/ (- h dim) 2) dim dim Red))<br>  )<br>;; events<br>  (lambda (t x y)<br>    (if (= t EVENT_KEYPRESS) (begin<br>      (if (= x EVENT_KEYESCAPE) (terminate))))<br>    (glgui-event gui t x y))<br>;; termination<br>  (lambda () #t)<br>;; suspend<br>  (lambda () (glgui-suspend))<br>;; resume<br>  (lambda () (glgui-resume))<br>)<br><br>;; eof<br><br><br>repl.scm:<br><br><br>;;; $Id: repl.scm,v 1.1 2013/03/10 16:24:54 daniel Exp daniel $<br>        ;;; $Name: $<br><br><br><br><br>        ;; ------------------remote REPL -------------------------------------------------------------<br>        (define (ide-repl-pump ide-repl-connection in-port out-port tgroup)<br><br><br>        (define m (make-mutex))<br><br><br>        (define
 (process-input)<br>        (let loop ((state 'normal))<br>        (let ((c (read-char ide-repl-connection)))<br>        (if (not (eof-object? c))<br>        (case state<br>        ((normal)<br>        (if (char=? c #\xff) ;; telnet IAC (interpret as command) code?<br>        (loop c)<br>        (begin<br>        (mutex-lock! m)<br>        (if (char=? c #\x04) ;; ctrl-d ?<br>        (close-output-port out-port)<br>        (begin<br>        (write-char c out-port)<br>        (force-output out-port)))<br>        (mutex-unlock! m)<br>        (loop state))))<br>        ((#\xfb) ;; after WILL command?<br>     
   (loop 'normal))<br>        ((#\xfc) ;; after WONT command?<br>        (loop 'normal))<br>        ((#\xfd) ;; after DO command?<br>        (if (char=? c #\x06) ;; timing-mark option?<br>        (begin ;; send back WILL timing-mark<br>        (mutex-lock! m)<br>        (write-char #\xff ide-repl-connection)<br>        (write-char #\xfb ide-repl-connection)<br>        (write-char #\x06 ide-repl-connection)<br>        (force-output ide-repl-connection)<br>        (mutex-unlock! m)))<br>        (loop 'normal))<br>        ((#\xfe) ;; after DONT command?<br>        (loop 'normal))<br>        ((#\xff) ;; after IAC command?<br>        (case
 c<br>        ((#\xf4) ;; telnet IP (interrupt process) command?<br>        (for-each<br>        ##thread-interrupt!<br>        (thread-group->thread-list tgroup))<br>        (loop 'normal))<br>        ((#\xfb #\xfc #\xfd #\xfe) ;; telnet WILL/WONT/DO/DONT command?<br>        (loop c))<br>        (else<br>        (loop 'normal))))<br>        (else<br>        (loop 'normal)))))))<br><br><br>        (define (process-output)<br>        (let loop ()<br>        (let ((c (read-char in-port)))<br>        (if (not (eof-object? c))<br>        (begin<br>        (mutex-lock! m)<br>        (write-char c
 ide-repl-connection)<br>        (force-output ide-repl-connection)<br>        (mutex-unlock! m)<br>        (loop))))))<br><br><br>        (let ((tgroup (make-thread-group 'repl-pump #f)))<br>        (thread-start! (make-thread process-input #f tgroup))<br>        (thread-start! (make-thread process-output #f tgroup))))<br><br><br>        (define (make-ide-repl-ports ide-repl-connection tgroup)<br>        (receive (in-rd-port in-wr-port) (open-string-pipe '(direction: input permanent-close: #f))<br>        (receive (out-wr-port out-rd-port) (open-string-pipe '(direction: output))<br>        (begin<br><br><br>        ;; Hack... set the names of the ports for usage with gambit.el<br>        (##vector-set! in-rd-port 4
 (lambda (port) '(stdin)))<br>        (##vector-set! out-wr-port 4 (lambda (port) '(stdout)))<br><br><br>        (ide-repl-pump ide-repl-connection out-rd-port in-wr-port tgroup)<br>        (values in-rd-port out-wr-port)))))<br><br><br>        (define repl-channel-table (make-table test: eq?))<br><br><br>        (set! ##thread-make-repl-channel<br>        (lambda (thread)<br>        (let ((tgroup (thread-thread-group thread)))<br>        (or (table-ref repl-channel-table tgroup #f)<br>        (##default-thread-make-repl-channel thread)))))<br><br><br>        (define (setup-ide-repl-channel ide-repl-connection tgroup)<br>        (receive (in-port out-port) (make-ide-repl-ports ide-repl-connection tgroup)<br>       
 (let ((repl-channel (##make-repl-channel-ports in-port out-port)))<br>        (table-set! repl-channel-table tgroup repl-channel))))<br><br><br>        (define (start-ide-repl)<br>        (##repl-debug-main))<br><br><br>        (define repl-server-address "*:7000")<br><br><br>        (define (repl-server)<br>        (let ((server<br>        (open-tcp-server<br>        (list server-address: repl-server-address<br>        reuse-address: #t))))<br>        (let loop ()<br>        (let* ((ide-repl-connection<br>        (read server))<br>        (tgroup<br>        (make-thread-group 'repl-service #f))<br>        (thread<br>       
 (make-thread<br>        (lambda ()<br>        (setup-ide-repl-channel ide-repl-connection tgroup)<br>        (start-ide-repl))<br>        'repl<br>        tgroup)))<br>        (thread-start! thread)<br>        (loop)))))<br><br><br>        (define (start-repl-server)<br>        (thread-start! (make-thread (lambda () (repl-server)))))<br><br><br>        ;-----------------------------------------------------------------------------------------------------------------<br><br><br><br><br>_______________________________________________<br>Gambit-list mailing list<br><a ymailto="mailto:Gambit-list@iro.umontreal.ca" href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br><a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list"
 target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br><br><br></div> </div> </div>  </div></body></html>