Changeset 3583

Show
Ignore:
Timestamp:
07/23/08 14:48:58 (4 months ago)
Author:
hans
Message:

*** empty log message ***

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/projects/bos/m2/test-allocation.lisp

    r3582 r3583  
    3838                    (values-list (bos.web::dequeue border-queue))) 
    3939                  (go retry)))))))))) 
     40 
     41(defun try-alloc (n) 
     42  (let* ((area (first (remove-if-not #'allocation-area-active-p (class-instances 'allocation-area)))) 
     43         (area-left (allocation-area-left area)) 
     44         (area-top (allocation-area-top area)) 
     45         (area-width (allocation-area-width area)) 
     46         (area-height (allocation-area-height area)) 
     47         (area-right (+ area-left area-width)) 
     48         (area-bottom (+ area-top area-height))) 
     49    (labels ((allocatable-p (x y) 
     50               (and (<= area-left x area-right) 
     51                    (<= area-top y area-bottom) 
     52                    (not (m2-contract (ensure-m2 x y)))))) 
     53      (loop 
     54           (let ((x (+ area-left (random area-width))) 
     55                 (y (+ area-top (random area-height)))) 
     56             (unless (m2-contract (ensure-m2 x y)) 
     57               (let ((result (try-allocation n x y #'allocatable-p))) 
     58                 (when result 
     59                   (return result))))))))) 
     60         
     61 
     62