-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
handler.lisp
53 lines (45 loc) · 1.34 KB
/
handler.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#|
This file is a part of Clack package.
URL: http://github.com/fukamachi/clack
Copyright (c) 2011 Eitaro Fukamachi <e.arrows@gmail.com>
Clack is freely distributable under the LLGPL License.
|#
(in-package :cl-user)
(defpackage clack.handler
(:use :cl)
(:import-from :clack.file-watcher
:stop-watching)
(:import-from :clack.util
:find-handler)
(:import-from :bordeaux-threads
:threadp
:destroy-thread))
(in-package :clack.handler)
(cl-syntax:use-syntax :annot)
@export
(defclass <handler> ()
((server-name :type keyword
:initarg :server-name
:accessor server-name)
(acceptor :initarg :acceptor
:accessor acceptor)))
@export
(defgeneric stop (handler)
(:documentation
"Stop the Clack server. Currently only works with Hunchentoot.")
(:method ((this <handler>))
(let ((handler-package (find-handler (server-name this))))
(stop-watching this)
(let ((acceptor (acceptor this)))
(if (bt:threadp acceptor)
(progn
(bt:destroy-thread acceptor)
(sleep 0.5))
(funcall (intern (string '#:stop) handler-package) acceptor))))))
(doc:start)
@doc:NAME "
Clack.Handler - Class for Handler
"
@doc:AUTHOR "
* Eitaro Fukamachi (e.arrows@gmail.com)
"