anchor.diff:       (unless (zerop (boole boole-and %zmq::revents %zmq::+pollin+))
          :pollerr))))
   
  +(defclass poll-item ()
  +  ((socket :initarg :socket
  +           :reader socket)
  +   (events :initarg :events)
  +   (revents :reader revents)
  +   (poll-item-ptr)))
  +
  +(defmethod (setf events) (value (poll-item poll-item))
  +  (with-slots ((events events)
  +               (poll-item-ptr poll-item-ptr))
  +      poll-item
  +    (setf events (alexandria:ensure-list value))
  +    (when poll-item-ptr
  +      (set-events poll-item))))
  +
  +(defun make-poll-item (socket &rest events)
  +  (make-instance 'poll-item :socket socket :events events))
  +
   (defclass poll-list ()
  -  ((poll-items
  -    :initarg :poll-items
  -    :reader poll-items)
  -   (poll-count
  -    :initarg :poll-count
  -    :reader poll-count)))
  +  ((poll-items)
  +   (poll-array :initform (cffi:foreign-alloc '%zmq::pollitem-t :count 8))
  +   (poll-count :reader poll-count
  +               :initform 0)))
  +
  +(defmethod (setf poll-items) (value (poll-list poll-list))
  +  (with-slots ((poll-array poll-array)
  +               (poll-count poll-count)
  +               (poll-items poll-items))
  +      poll-list
  +    (loop
  +     :for poll-item :in (alexandria:ensure-list value)
  +     :for index :from 0
  +     :as poll-item-ptr = (cffi:mem-aref poll-array '%zmq::pollitem-t index)
  +     :do
  +     (setf (slot-value poll-item 'poll-item-ptr) poll-item-ptr)
  +     (set-events poll-item)     
  +     :finally (setf poll-count (1+ index)))
  +    (setf poll-items (alexandria:ensure-list value))
  +    value))
  +
  +(defmethod initialize-instance :after ((poll-list poll-list) &key poll-items)
  +  (when poll-items
  +    (setf (poll-items poll-list) poll-items)))
  +
  +(defun make-poll-list (&rest poll-items)
  +  (make-instance 'poll-list :poll-items poll-items))
  +
  +(defun destroy-poll-list (poll-list)
  +  (cffi:foreign-free (slot-value poll-list 'poll-array)))
  +
   
   (defun poll (poll-list &optional (timeout -1) (eintr-retry t))
  -  (let ((evts (%zmq:with-eintr-retry eintr-retry
  -                  (%zmq::poll (poll-items poll-list)
  -                              (poll-count poll-list)
  -                              timeout))))
  -    (unless (zerop evts)
  -      (values evts))))
  +  (with-slots ((poll-items poll-items)
  +               (poll-array poll-array)
  +               (poll-count poll-count))
  +      poll-list
  +    (loop
  +     :for item :in poll-items
  +     :for index :from 0
  +     :do
  +     (setf (slot-value item 'revents) nil))
  +    (let ((evts (%zmq:with-eintr-retry eintr-retry
  +                  (%zmq::poll poll-array poll-count timeout))))
  +      (unless (zerop evts)
  +        (loop
  +         :for item :in poll-items
  +         :for index :below poll-count
  +         :do
  +         (setf (slot-value item 'revents)
  +               (has-events-p (cffi:mem-aref poll-array
  +                                            '%zmq::pollitem-t
  +                                            index))))
  +        (values t evts)))))
   
  -(defmacro with-poll-list ((symbol &rest poll-items) &body body)
  -  (alexandria:with-gensyms (poll-array)
  -    `(cffi:with-foreign-object
  -         (,poll-array '%zmq::pollitem-t ,(length poll-items))
  -       (let ((,symbol (make-instance 'poll-list
  -                                     :poll-items ,poll-array
  -                                     :poll-count ,(length poll-items)))
  -             ,@(loop :for item :in poll-items
  -                     :for index :from 0
  -                     :collect `(,(first item)
  -                                (cffi:mem-aref ,poll-array
  -                                               '%zmq::pollitem-t
  -                                               ,index))))
  -         ,@(loop :for item :in poll-items
  -                 :for index :from 0
  -                 :collect `(set-events ,(second item)
  -                                       (cffi:mem-aref ,poll-array
  -                                                      '%zmq::pollitem-t
  -                                                      ,index)
  -                                       ,@(cddr item)))
  -         ,@body))))
  +(defmacro with-poll-list ((poll-list &rest poll-items) &body body)
  +  `(let ((,poll-list (make-poll-list ,@poll-items)))
  +     (unwind-protect
  +          ,@body
  +       (destroy-poll-list ,poll-list))))
  
positive.code: 
  (in-package #:poll)
  
  (defgeneric set-events (socket poll-item-ptr &rest events))
  
  (defmethod set-events ((socket socket:socket) poll-item-ptr &rest events)
    (cffi:with-foreign-slots ((%zmq::socket %zmq::events)
                              poll-item-ptr
                              %zmq::pollitem-t)
      (setf %zmq::socket (slot-value socket 'socket:ptr)
  
negative.code:                           (if (member :pollout events) %zmq::+pollout+ 0)
                            (if (member :pollerr events) %zmq::+pollerr+ 0)))))
  
  #++(defmethod set-events ((fd t) poll-item-ptr &rest events)
    (cffi:with-foreign-slots ((%zmq::fd %zmq::events)
                              poll-item-ptr
                              %zmq::pollitem-t)
  