Changeset 3900
- Timestamp:
- 09/15/08 16:46:00 (2 months ago)
- Files:
-
- trunk/projects/bos/m2/allocation.lisp (modified) (4 diffs)
- trunk/projects/bos/m2/m2.lisp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/projects/bos/m2/allocation.lisp
r3899 r3900 9 9 (vertices :reader allocation-area-vertices :initarg :vertices) 10 10 (total-m2s :reader allocation-area-total-m2s) 11 (free-m2s : transient t :writer (setf allocation-area-free-m2s)) ;free-m2s reader defined below11 (free-m2s :accessor allocation-area-free-m2s) 12 12 (bounding-box :transient t :reader allocation-area-bounding-box)) 13 13 (:documentation … … 28 28 (allocation-area-width allocation-area) 29 29 (allocation-area-height allocation-area) 30 (allocation-area-active-p allocation-area) 30 (allocation-area-active-p allocation-area) 31 31 (store-object-id allocation-area)))) 32 32 33 (defmethod allocation-area-free-m2s ((area allocation-area))34 (flet ((compute-free-m2s ()35 (with-slots (total-m2s free-m2s) area36 (setf free-m2s (- total-m2s (calculate-allocated-m2-count area))))))37 (if (slot-boundp area 'free-m2s)38 (slot-value area 'free-m2s)39 (compute-free-m2s))))40 41 33 (defmethod initialize-persistent-instance :after ((allocation-area allocation-area) &key) 42 (with-slots (total-m2s) allocation-area 43 (setf total-m2s (calculate-total-m2-count allocation-area))) 34 (with-slots (total-m2s free-m2s) allocation-area 35 (setf total-m2s (calculate-total-m2-count allocation-area)) 36 (setf free-m2s (- total-m2s (calculate-allocated-m2-count allocation-area)))) 44 37 ;; FIXME probably we dont need this and should rely on *rect-publisher* 45 38 (dolist (tile (allocation-area-tiles allocation-area)) … … 52 45 (notify-tiles allocation-area)) 53 46 54 (defmethod initialize-transient-instance :after ((allocation-area allocation-area)) 47 (defmethod initialize-transient-instance :after ((allocation-area allocation-area)) 55 48 (notify-tiles allocation-area)) 56 49 … … 352 345 (when result 353 346 (assert (alexandria:setp result :test #'equal)) 354 (assert (= n (length result))) 347 (assert (= n (length result))) 355 348 (return result)) 356 349 (when (> (get-internal-real-time) deadline) trunk/projects/bos/m2/m2.lisp
r3895 r3900 35 35 :index-reader m2-at 36 36 :index-initargs (:width +width+ 37 :height +width+38 :tile-size +m2tile-width+39 :tile-class 'image-tile))))37 :height +width+ 38 :tile-size +m2tile-width+ 39 :tile-class 'image-tile)))) 40 40 41 41 (defmethod print-object ((m2 m2) stream) … … 56 56 (defun ensure-m2 (&rest coords) 57 57 (or (m2-at coords) 58 (destructuring-bind (x y) coords 58 (destructuring-bind (x y) coords 59 59 (make-object 'm2 :x x :y y)))) 60 60 … … 265 265 (expires :read :documentation "universal time which specifies the 266 266 time the contract expires (is deleted) when it has not been paid for" 267 :initform nil)267 :initform nil) 268 268 (largest-rectangle :update)) 269 269 (:default-initargs … … 284 284 (equal (class-of object) (find-class 'contract))) 285 285 286 (defmethod initialize-persistent-instance :after ((contract contract) &key )286 (defmethod initialize-persistent-instance :after ((contract contract) &key area) 287 287 (pushnew contract (sponsor-contracts (contract-sponsor contract))) 288 288 (dolist (m2 (contract-m2s contract)) 289 (setf (m2-contract m2) contract)) 289 (setf (m2-contract m2) contract) 290 (decf (allocation-area-free-m2s area))) 290 291 (setf (contract-largest-rectangle contract) 291 292 (contract-compute-largest-rectangle contract)) … … 529 530 " 530 531 m2-count (store-object-id sponsor))) 531 (error 'allocation-areas-exhausted :numsqm m2-count)) 532 ;; FREE-M2S might be lazily computed at his point, before it is 533 ;; decremented. If this happens, the m2s must still be free. 534 (decf (allocation-area-free-m2s area) m2-count) 532 (error 'allocation-areas-exhausted :numsqm m2-count)) 535 533 (make-object 'contract 536 534 :sponsor sponsor 537 535 :date date 538 536 :m2s m2s 537 :area area 539 538 :expires expires 540 539 :download-only download-only
