Skip to content

Latest commit

 

History

41 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

  1. Examples
    1. Create a queue, send and receive a message, unlink queue.
    2. Open existing queue and wait for a message for 1 second
    3. Create a queue, try to receive a message and return immediately because a call would block
  2. Usage
  3. Manual
  4. Implementations
    1. Tests succeeded
    2. Tests failed
      1. abcl
      2. clasp
  5. Todo
    1. mqnotify
    2. with-pointer-to-vector-data
    3. publish to quicklisp and awesome-cl

Common Lisp bindings to POSIX message queues. Contributions and questions are welcome.

POSIX message queue is an IPC (Inter-Process Communication) method that is easy to use and quick to setup.

Examples

Create a queue, send and receive a message, unlink queue.

(with-open-queue (mq "/myqueue" :open-flags '(:read-write :create)
                                :max-messages 5 :message-size 10)
  ;; Messages are ordered based on priority.  High priority messages are placed
  ;; at the beginning.
  (send-string mq "hello" 4)            ; 4 is priority
  (multiple-value-bind (msg-string priority) (receive-string mq)
    (when (and (string= "hello" msg-string) (= 4 priority))
      (print "It works!"))))
(unlink "/myqueue")

Open existing queue and wait for a message for 1 second

(with-open-queue (mq "/myqueue" :open-flags '(:read-only))
  (multiple-value-bind (msg priority)
      ;; Timestamps are absolute
      (timed-receive-string mq (local-time:timestamp+ (local-time:now) 1 :sec))
    (when (eq :connection-timed-out msg)
      (print "Timed out!"))))
(unlink "/myqueue")

Create a queue, try to receive a message and return immediately because a call would block

(with-open-queue (mq "/myqueue" :open-flags '(:read-only :create :non-blocking))
  (multiple-value-bind (msg priority) (receive-string mq)
    (when (eq :try-again msg)
      (print "Would block!"))))
(unlink "/myqueue")

Usage

This library uses local-time library for timestamps. All of the exported symbols are documented in details through the internal common lisp documentation system.

Implementations

Tests succeeded

  • sbcl
  • ecl
  • ccl
  • clisp

Tests failed

abcl

First of all, slynk failed to load. Quicklisp and cl-posix-mqueue, loaded just fine. Tests failed. When I started using cl-posix-mqueue manually, memory errors were printed. After that, core dumped. Maybe cffi should be set differently for jvm.

clasp

Could not build implementation on my machine

Todo

mqnotify

with-pointer-to-vector-data

It does unnecessary writes and reads on implementations where direct access to vectors is not supported. Maybe on receive it should only read and on send it should only write.

publish to quicklisp and awesome-cl

About

Common Lisp bindings to posix mqueue

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages