Giter VIP home page Giter VIP logo

queues's People

Contributors

oconnore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

queues's Issues

SIMPLE-CQUEUE does not work in SBCL

The following code gives me an error in SBCL 1.3.10:

(let ((q (queues:make-queue :simple-cqueue)))
  (queues:qpush q 42)
  (queues:qpop q))

The backtrace looks like this:

Recursive lock attempt #<SB-THREAD:MUTEX "queue-lock" owner: #<SB-THREAD:THREAD "repl-thread" RUNNING {1002E58003}>>.
   [Condition of type SIMPLE-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1002E58003}>)

Backtrace:
  0: (SB-THREAD::%TRY-MUTEX #<unavailable argument> #<unavailable argument>)
  1: (SB-THREAD:GRAB-MUTEX #<SB-THREAD:MUTEX "queue-lock" owner: #<SB-THREAD:THREAD "repl-thread" RUNNING {1002E58003}>> :WAITP T :TIMEOUT NIL)
  2: ((FLET #:WITHOUT-INTERRUPTS-BODY-359 :IN SB-THREAD::CALL-WITH-MUTEX))
  3: (SB-THREAD::CALL-WITH-MUTEX #<CLOSURE (FLET SB-THREAD::WITH-MUTEX-THUNK :IN QUEUES:QSIZE) {6A4CBFB}> #<SB-THREAD:MUTEX "queue-lock" owner: #<SB-THREAD:THREAD "repl-thread" RUNNING {1002E58003}>> NIL T..
  4: ((:METHOD QUEUES:QSIZE (QUEUES:SIMPLE-CQUEUE)) #<QUEUES:SIMPLE-CQUEUE 42 [1]>) [fast-method]
  5: ((:METHOD QUEUES:QPOP (QUEUES:SIMPLE-QUEUE)) #<QUEUES:SIMPLE-CQUEUE 42 [1]> NIL) [fast-method]
  6: ((FLET #:WITHOUT-INTERRUPTS-BODY-359 :IN SB-THREAD::CALL-WITH-MUTEX))
  7: (SB-THREAD::CALL-WITH-MUTEX #<CLOSURE (FLET SB-THREAD::WITH-MUTEX-THUNK :IN QUEUES:QPOP) {6A4CE2B}> #<SB-THREAD:MUTEX "queue-lock" owner: #<SB-THREAD:THREAD "repl-thread" RUNNING {1002E58003}>> NIL T ..
  8: ((:METHOD QUEUES:QPOP (QUEUES:SIMPLE-CQUEUE)) #<QUEUES:SIMPLE-CQUEUE 42 [1]>) [fast-method]
  9: (SB-INT:SIMPLE-EVAL-IN-LEXENV (LET ((Q #)) (QUEUES:QPUSH Q 42) (QUEUES:QPOP Q)) #<NULL-LEXENV>)
 10: (EVAL (LET ((Q #)) (QUEUES:QPUSH Q 42) (QUEUES:QPOP Q)))

Switch WITH-LOCK-HELD to WITH-RECURSIVE-LOCK-HELD in cqueue.lisp helps, but is that the right fix?

qpop stops working, but qpush doesn't, so the queue grows boundlessly

Cause: queue.lisp function qpush grows the underlying vector in two ways. Either by copying the tail or the head. In the latter, it needs to also update the "start" pointer, but doesn't.

Test:

(in-package queues)
(setf *minimum-size* 2)
(in-package cl-user)
(defparameter q (make-queue :simple-queue))
;notation: (start size vector)
(qpush q 'a) ;(0 1 (a nil))
(qpush q 'b) ;(0 2 (a b))
(qpop q) ;(1 1 (nil b))
(qpush q 'c) ;(1 2 (c b))
(qpush q 'd) ;wrongly (1 3 (c nil nil d)) instead of (3 3 (c d nil b))
;lost b, and also stuck forever as qpop's "unless" prevents popping nil
(print-queue q) ;shows (nil nil d)

Fix:

--- queues-20120703-git.orig/queue.lisp 2013-02-12 05:05:50.000000000 +0000
+++ quicklisp/dists/quicklisp/software/queues-20120703-git/queue.lisp   2013-03-26 05:49:16.000000000 +0000
@@ -111,7 +111,8 @@
               for x from start below vec-size
               for y from (- new-size (- vec-size start))
               do (setf (aref vector y) (aref vector x)
-               (aref vector x) nil)))))))
+               (aref vector x) nil))
+           (setf (start-of queue) (- new-size (- vec-size start))))))))
     (setf (aref vector (%queue-last queue))
      element)
     (incf (size-of queue))

Queues should just work after quickloading

Please change your weird loading system to be like it is for most packages. No one wants to read up on how to load after loading. Using (queues:make-queue :simple-queue) results in "SIMPLE-QUEUE is not loaded"...

Typo in Readme API

The make-queue function for the priority-queue, the parameter key in your code is 'compare', not 'comparison' as written in the Readme.

undefined function: QUEUES::MAKE-PRIORITY-QUEUE

This has been a warning for the longest time:

; file: /Users/robert/quicklisp/dists/quicklisp/software/queues-20170124-git/priority-queue.lisp
; in:
;      DEFMETHOD QUEUES:QUEUE-MERGE-SAFE (QUEUES:PRIORITY-QUEUE QUEUES:PRIORITY-QUEUE)
;     (QUEUES::MAKE-PRIORITY-QUEUE :COMPARE
;      (QUEUES:QUEUE-COMPARISON QUEUES::QUEUE1))
; 
; caught STYLE-WARNING:
;   undefined function: QUEUES::MAKE-PRIORITY-QUEUE
; 
; compilation unit finished
;   Undefined function:
;     QUEUES::MAKE-PRIORITY-QUEUE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.