aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Olaechea <pirata@gmail.com>2019-01-20 21:44:21 -0500
committerJavier Olaechea <pirata@gmail.com>2019-01-20 21:44:21 -0500
commit153545529b3f8156efcbb749c8fc83525f15cfa3 (patch)
tree022af64be54ba6c2841df5abb68e4265aec7ac63
parentbe618c268c430a59fad19ff3d247d7f091d859da (diff)
downloadcl-xcb-cookie-wip.tar.gz
Sketch how to generate cookiescookie-wip
-rw-r--r--src/connection.lisp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/connection.lisp b/src/connection.lisp
index 5f33373..13219dc 100644
--- a/src/connection.lisp
+++ b/src/connection.lisp
@@ -126,3 +126,34 @@ corresponding SOCKET."
(0 (read-setup-failed stream))
(1 (read-setup stream))
(2 :todo-authenticate))))
+
+;; uint64_t xcb_send_request_with_fds64(xcb_connection_t *c, int flags, struct iovec *vector,
+
+;; any checked_request allocates a cookie
+
+;; TODO allocate a cookie with lock
+
+;; Wouldbe option if I was using defstruct sb-ext:atomic-incf could store the cookie ina cons to get away with using it in a slot
+
+#+using-atomic-incf
+(defun cookie (connection)
+ ;; TODO: Would a mod (expt 2 16) suffice?
+ (sb-ext:atomic-incf (cdr (cookie-counter connection))))
+
+(defun cookie (connection)
+ ;; TODO: Would a mod (expt 2 16) suffice?
+ (sb-thread:with-mutex ((connection-lock connection))
+ (prog1
+ (cookie-counter connection)
+ (incf (cookie-counter connection)))))
+
+;; Should we use change-class
+;; FIXME: Should we keep the counter for the next available cookie here?
+(defclass connection (setup-request)
+ ((mutex :initform (make-mutex :name "xcb-connection")
+ :reader connection-lock)
+ ;; We should store the endianness when we send the setup-request
+ (endianness :initarg :endianess :reader connection-endianness) )
+ (:documentation "Holds of the information about the current
+ connection. Analogous to xcb_connection_t and to a certain exent Xlib's
+ display structure."))