-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to a queue-based representation for the scrobble cache and mak…
…e ALL scrobbles go through it, network failure or not. Caching should only happen for scrobbles, not other calls so this is a nice simplification. Other assorted cleanups to the API and cl-store usage.
- Loading branch information
Showing
6 changed files
with
64 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(in-package :cl-scrobbler) | ||
|
||
|
||
;;;; This queue code courtesy of Peter Norvig and Richard Water's technical | ||
;;;; paper "Implementing Queues in Lisp" published by the ACM in 1991. | ||
;;;; It is more easily, and freely, available in 'Some Useful Lisp Algorithms' | ||
;;;; which is available online at http://www.merl.com/papers/docs/TR91-04.pdf | ||
|
||
;;; This implementation taken from Figure 17 and ever so slightly adapted. | ||
;;; TODO: Read the paper. Then scrap the CDR coding. It's 2011 after all. | ||
|
||
(defun make-queue () | ||
(let ((queue (list nil))) | ||
(cons queue queue))) | ||
|
||
(defun queue-elements (queue) | ||
(cdar queue)) | ||
|
||
(defun empty-queue-p (queue) | ||
(null (queue-elements queue))) | ||
|
||
(defun queue-front (queue) | ||
(cadar queue)) | ||
|
||
(defun dequeue (queue) | ||
(car (setf (car queue) (queue-elements queue)))) | ||
|
||
(defun enqueue (queue item) | ||
(setf (cdr queue) | ||
(setf (cddr queue) (list item)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters