remove unneeded dependancy

master
Avril 5 years ago
parent 1c7954c451
commit 111f317d20
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -2,8 +2,6 @@
(in-package :cl-box)
(flan-utils:enable-all-readers)
(defstruct %box
value
lock)
@ -11,7 +9,8 @@
(defmacro %atomic (box &body re)
`(bt:with-lock-held ((%box-lock ,box))
,@re))
[
(mapc 'export (list
(defun make-box (&optional value)
(let ((b (make-%box)))
(setf (%box-value b) value)
@ -62,7 +61,7 @@
,@things)
(<-! ,name)))))
]
))
(defun test ()
(let ((box (make)))

@ -6,8 +6,7 @@
:license "None"
:version "0.0.1"
:serial t
:depends-on ( :flan-utils
:bt-semaphore )
:depends-on ( :bt-semaphore )
:components ((:file "package")
(:file "cl-channel")
(:file "cl-box")

@ -2,13 +2,13 @@
(in-package :cl-channel)
(flan-utils:enable-all-readers)
(defstruct %queue
internal
mutex)
[
(mapc 'export (list
(defun make-queue (&optional (from nil))
(let ((q (make-%queue)))
(setf (%queue-internal q) from)
@ -31,7 +31,7 @@
(defun queue-clear (q)
(bt:with-lock-held ((%queue-mutex q))
(setf (%queue-internal q) nil)))
]
))
(defstruct %channel
internal
@ -49,7 +49,8 @@
(defun sigall (sem)
(bt-sem:signal-semaphore sem (bt-sem:semaphore-waiters sem)))
[
(mapc 'export (list
(defun make-channel (&optional (max 0))
(let ((c (make-%channel)))
(setf (%channel-internal c) (make-queue))
@ -71,7 +72,7 @@
(defun <- (chan)
(let ((out nil)
(rout nil))
(loop while (and (null out) ¬(closed chan)) do
(loop while (and (null out) (not (closed chan))) do
(progn
(if (> (poll chan) 0)
(%atomic chan
@ -83,15 +84,15 @@
(if (closed chan) (values nil nil) (values rout t))))
(defun -> (chan item)
(loop while (and ¬(closed chan) (> (%channel-max chan) 0) (%atomic chan (>= (queue-poll (%channel-internal chan)) (%channel-max chan))))
(loop while (and (not (closed chan)) (> (%channel-max chan) 0) (%atomic chan (>= (queue-poll (%channel-internal chan)) (%channel-max chan))))
do (bt-sem:wait-on-semaphore (%channel-rel-send)))
(let ((lv (%atomic chan
(if ¬(if (or (%channel-closed chan) (and (> (%channel-max chan) 0) (>= (queue-poll (%channel-internal chan)) (%channel-max chan))))
(if (not (if (or (%channel-closed chan) (and (> (%channel-max chan) 0) (>= (queue-poll (%channel-internal chan)) (%channel-max chan))))
nil
(progn
(queue-> (%channel-internal chan) item)
(bt-sem:signal-semaphore (%channel-rel-recv chan) 1)
t))
t)))
(if (%channel-closed chan) nil 'reset)
t))))
(if (eq lv 'reset)
@ -110,9 +111,10 @@
(defmacro make ()
`(make-channel))
]
(defun test ()
))
#|(defun test ()
(let ((chan (make-channel)))
$(progn
(loop while ¬(closed chan) do (let ((val (<- chan)))
@ -122,5 +124,9 @@
(release chan))))
(print "Thread end")
(print "."))
$(loop while ¬(closed chan) do
(progn
(sleep 2)
(-> chan 'teste)))
(loop while ¬(closed chan) do (-> chan (write-to-string (read)))))
(print "End"))
(print "End"))|#

@ -2,8 +2,6 @@
(in-package :cl-dispatcher)
(flan-utils:enable-all-readers)
(defstruct %dispatcher
hooks
lock)
@ -12,7 +10,8 @@
`(bt:with-lock-held ((%dispatcher-lock disp))
,@thing))
[
(mapc 'export (list
(defun make-dispatcher ()
(let ((d (make-%dispatcher)))
(setf (%dispatcher-hooks d ) nil)
@ -33,7 +32,7 @@
(let ((hooks (assoc name (%dispatcher-hooks disp))))
(if (null hooks)
nil
(mapc #'(lambda (y) $(funcall y x)) (cdr hooks))))))
(mapcar #'(lambda (y) (bt:make-thread (funcall y x))) (cdr hooks))))))
(defun sig-serial (disp name &optional (x nil))
(%atomic disp
@ -41,7 +40,7 @@
(if (null hooks)
nil
(mapc #'(lambda (y) (funcall y x)) (cdr hooks))))))
]
))
(defun test ()
(let ((d (make)))
@ -51,4 +50,3 @@
(sig-serial d "test" 'uwu)
(print 'signalled)))

Loading…
Cancel
Save