Skip to content

Commit

Permalink
with-sockets macro
Browse files Browse the repository at this point in the history
  • Loading branch information
joelreymont committed Sep 6, 2011
1 parent 3e23d1d commit 945e300
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions zeromq-api.lisp
Expand Up @@ -104,6 +104,15 @@
(progn ,@body)
(zmq_close ,socket))))

(defmacro with-sockets (sockets &body body)
(loop for (socket context type) in sockets
collect `(,socket (zmq_socket ,context ,(lookup-constant type))) into bindings
collect `(zmq_close ,socket) into cleanup
finally (return `(let ,bindings
(unwind-protect
(progn ,@body)
(progn ,@cleanup))))))

(defun send (s msg &optional flags)
(%send s (msg-raw msg) (or flags 0)))

Expand Down

0 comments on commit 945e300

Please sign in to comment.