Commit 30a107e0 authored by Martin Sustrik's avatar Martin Sustrik

timeout parameter for zmq_poll added in cl binding

parent 20a8edcf
...@@ -146,7 +146,7 @@ The string must be freed with FOREIGN-STRING-FREE." ...@@ -146,7 +146,7 @@ The string must be freed with FOREIGN-STRING-FREE."
(setf (mem-aref int :long 0) value) (setf (mem-aref int :long 0) value)
(%setsockopt socket option int (foreign-type-size :long)))))) (%setsockopt socket option int (foreign-type-size :long))))))
(defun poll (items) (defun poll (items &optional (timeout -1))
(let ((len (length items))) (let ((len (length items)))
(with-foreign-object (%items 'pollitem len) (with-foreign-object (%items 'pollitem len)
(dotimes (i len) (dotimes (i len)
...@@ -156,14 +156,16 @@ The string must be freed with FOREIGN-STRING-FREE." ...@@ -156,14 +156,16 @@ The string must be freed with FOREIGN-STRING-FREE."
(setf socket (pollitem-socket item) (setf socket (pollitem-socket item)
fd (pollitem-fd item) fd (pollitem-fd item)
events (pollitem-events item))))) events (pollitem-events item)))))
(let ((ret (%poll %items len))) (let ((ret (%poll %items len timeout)))
(if (> ret 0) (cond
((zerop ret) nil)
((> ret 0)
(loop for i below len (loop for i below len
for revent = (foreign-slot-value (mem-aref %items 'pollitem i) for revent = (foreign-slot-value (mem-aref %items 'pollitem i)
'pollitem 'pollitem
'revents) 'revents)
collect (setf (pollitem-revents (nth i items)) revent)) collect (setf (pollitem-revents (nth i items)) revent)))
(error (convert-from-foreign (%strerror *errno*) :string))))))) (t (error (convert-from-foreign (%strerror *errno*) :string))))))))
(defmacro with-polls (list &body body) (defmacro with-polls (list &body body)
`(let ,(loop for (name . polls) in list `(let ,(loop for (name . polls) in list
......
...@@ -231,7 +231,8 @@ ...@@ -231,7 +231,8 @@
(defcfun ("zmq_poll" %poll) :int (defcfun ("zmq_poll" %poll) :int
(items :pointer) (items :pointer)
(nitems :int)) (nitems :int)
(timeout :long))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Helper functions. ;; Helper functions.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment