Skip to content

Commit 64bd97e

Browse files
iamFIREcrackervindarel
authored andcommitted
Don't wrap SWANK:CREATE-SERVER inside BT:MAKE-THREAD
In general, a call to SWANK:CREATE-SERVER is not blocking (i.e. it creates a thread on its own), hence wrapping it inside BT:MAKE-THREAD is kind of redundant. The only situations for which a call to BT:MAKE-THREAD would be required are as if: - the underlying implementation does not support multi-threading, in which case, a call to BT:MAKE-THREAD would fail anyway - the user is explicitly forcing a _blocking_ communication style (i.e. `(setf swank:*communication-style* nil)`), but since we, as the users, are not enforcing that, then we should be good without that extra call While at it, I also: - made QL:QUICKLOAD calls consistent by specifying packages as strings (previously it was a mix of strings and keywords) - wrapped the infinite loop inside BT:MAKE-THREAD, that way the user can interact with the image while it's running (i.e. call BT:ALL-THREADS to confirm the Swank server is up and running)
1 parent 3033746 commit 64bd97e

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

debugging.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ To test this, let's define a function that prints forever.
376376
If needed, import the dependencies first:
377377

378378
~~~lisp
379-
(ql:quickload '(:swank :bordeaux-threads))
379+
(ql:quickload '("swank" "bordeaux-threads"))
380380
~~~
381381

382382

@@ -394,14 +394,14 @@ If needed, import the dependencies first:
394394
(format t "hello world ~a!~%" *counter*))
395395
396396
(defun runner ()
397-
(bt:make-thread (lambda ()
398-
(swank:create-server :port 4006))
399-
:name "swank")
397+
(swank:create-server :port 4006)
400398
(format t "we are past go!~%")
401-
(loop while t do
402-
(sleep 5)
403-
(dostuff)
404-
(incf *counter*)))
399+
(bt:make-thread (lambda ()
400+
(loop while t do
401+
(sleep 5)
402+
(dostuff)
403+
(incf *counter*)))
404+
:name "do-stuff"))
405405
406406
(runner)
407407
~~~
@@ -410,10 +410,15 @@ On the server, we can run this code with
410410

411411
sbcl --load demo.lisp
412412

413-
If you check with `(bt:all-threads)`, you'll see your Swank server running on port 4006:
414-
415-
#<SB-THREAD:THREAD "Swank 4006" RUNNING {1003A19333}>
413+
If you check with `(bt:all-threads)`, you'll see your Swank server running on port 4006, as well
414+
as the other thread ready to do stuff:
416415

416+
(#<SB-THREAD:THREAD "do-stuff" RUNNING {10027CEDC3}>
417+
#<SB-THREAD:THREAD "Swank Sentinel" waiting on:
418+
#<WAITQUEUE {10027D0003}>
419+
{10027CE8B3}>
420+
#<SB-THREAD:THREAD "Swank 4006" RUNNING {10027CEB63}>
421+
#<SB-THREAD:THREAD "main thread" RUNNING {1007C40393}>)
417422

418423
We do port forwarding on our development machine:
419424

0 commit comments

Comments
 (0)