Permalink
Browse files

with-sockets macro

  • Loading branch information...
1 parent 3e23d1d commit 945e30084c680277f3e3240050e08ed1480936e0 @wagerlabs wagerlabs committed Sep 6, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 zeromq-api.lisp
View
@@ -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)))

0 comments on commit 945e300

Please sign in to comment.