-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcqueue.lisp
More file actions
68 lines (53 loc) · 1.89 KB
/
cqueue.lisp
File metadata and controls
68 lines (53 loc) · 1.89 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;;;; **************************************************************************
;;;; **************************************************************************
;;;; *
;;;; * A simple, thread safe queue implementation
;;;; * by Eric O'Connor
;;;; *
;;;; **************************************************************************
;;;; **************************************************************************
(in-package :queues)
(eval-when (:compile-toplevel :load-toplevel :execute)
(use-package :bordeaux-threads))
;;;
;;; Class
;;;
(defclass simple-cqueue (simple-queue)
((lock :initform (make-recursive-lock "queue-lock")
:accessor lock-of)))
;;;
;;; Methods
;;;
(defmethod make-queue ((type (eql :simple-cqueue)) &key minimum-size copy)
(make-queue :simple-queue
:minimum-size minimum-size
:copy copy
:class 'simple-cqueue))
(defmethod qpush ((q simple-cqueue) el)
(with-recursive-lock-held ((lock-of q))
(call-next-method)))
(defmethod qpop ((q simple-cqueue) &optional empty)
(declare (ignore empty))
(with-recursive-lock-held ((lock-of q))
(call-next-method)))
(defmethod qtop ((q simple-cqueue) &optional empty)
(declare (ignore empty))
(with-recursive-lock-held ((lock-of q))
(call-next-method)))
(defmethod qsize ((q simple-cqueue))
(with-recursive-lock-held ((lock-of q))
(call-next-method)))
(defmethod qclear ((q simple-cqueue))
(with-recursive-lock-held ((lock-of q))
(call-next-method)))
(defmethod map-queue (fn (q simple-cqueue))
(with-recursive-lock-held ((lock-of q))
(call-next-method)))
(defmethod print-queue ((q simple-cqueue)
&optional (stream *standard-output*))
(declare (ignore stream))
(with-recursive-lock-held ((lock-of q))
(call-next-method)))
;;; ==================================================================
;;; EOF
;;; ==================================================================