1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: NIL -*-
3 ;;; Copyright (C) 2006-2008, Attila Lendvai <attila.lendvai@gmail.com>
5 ;;; This code is free software; you can redistribute it and/or
6 ;;; modify it under the terms of the version 2.1 of
7 ;;; the GNU Lesser General Public License as published by
8 ;;; the Free Software Foundation, as clarified by the
9 ;;; preamble found here:
10 ;;; http://opensource.franz.com/preamble.html
12 ;;; This program is distributed in the hope that it will be useful,
13 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU Lesser General
18 ;;; Public License along with this library; if not, write to the
19 ;;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 ;;; Boston, MA 02110-1301, USA
22 (in-package :net.sockets.cc
)
24 (defclass connection-multiplexer
()
26 :initform
"unnamed connection-multiplexer"
30 :initform
(bordeaux-threads:make-recursive-lock
"connection-multiplexer lock")
33 :initform
(make-array 128 :adjustable t
:initial-element nil
)
34 :accessor fd-
>connection-of
)
37 :accessor fd-multiplexer-of
)
40 :accessor shutdown-requested-p
)
42 :initform
(make-array 4 :adjustable t
:fill-pointer
0)
44 ;; configuration slots
47 :initarg
:worker-count
48 :accessor worker-count-of
)
51 :initarg
:external-format
52 :accessor external-format-of
)
54 :initarg
:fd-multiplexer-type
55 :accessor fd-multiplexer-type-of
)))
57 ;; TODO use progn combination
58 (defgeneric startup-connection-multiplexer
(multiplexer &key
&allow-other-keys
))
59 (defgeneric shutdown-connection-multiplexer
(multiplexer &key force
))
61 (defgeneric register-connection
(multiplexer connection
))
62 (defgeneric unregister-connection
(multiplexer connection
))
63 (defgeneric connection-registered-p
(multiplexer connection
))
65 (defclass connection-acceptor
(connection-multiplexer)
66 (;; slots for the runtime state
69 :initarg
:accepting-connection
70 :accessor accepting-connection-of
)
71 ;; configuration slots
73 :initarg
:connection-handler
74 :accessor connection-handler-of
75 :type
(or symbol function
))))
77 (defclass connection-with-continuation-mixin
()
80 :initarg
:continuation
81 :accessor continuation-of
)
83 :accessor wait-reason-of
85 :type
(member :read
:write
))))
87 (defclass bandwidth-information-mixin
()
89 :initform
(get-internal-real-time)
90 :accessor created-at-of
)
93 :accessor total-bytes-written-of
)
96 :accessor total-bytes-read-of
)))
98 (defgeneric notify-bytes-written
(connection count
))
99 (defgeneric average-writing-speed-of
(connection))
100 (defgeneric notify-bytes-read
(connection count
))
101 (defgeneric average-reading-speed-of
(connection))
103 (defclass connection
(connection-with-continuation-mixin
104 bandwidth-information-mixin
105 socket-stream-internet-active
)
108 ;; TODO why does connection inherit from socket-stream-internet-active and
109 ;; accepting-connection only contain a socket slot?
110 (defclass accepting-connection
(connection-with-continuation-mixin)
115 (defgeneric startup-acceptor
(acceptor &key address port
))
116 (defgeneric shutdown-acceptor
(acceptor &key force
))