port-status.lisp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ;; This structure contains some status information about a port, which can be queried with port-get-receive-status.
  2. ;;
  3. (defcstruct port-status-struct
  4. (port-set port)
  5. (seqno port-seqno)
  6. (mscount port-mscount)
  7. (queue-limit port-msgcount)
  8. (msgcount port-msgcount)
  9. (so-rights port-rights)
  10. (has-send-rights :boolean)
  11. (port-deleted-notification-requested :boolean)
  12. (no-senders-notification-requested :boolean))
  13. (defclass <port-status> ()
  14. ((ptr :initarg :ptr
  15. :accessor ptr
  16. :documentation "Pointer to a port-status structure."))
  17. (:documentation "Class for port-status objects containing port information."))
  18. (defmethod port-status-get ((status <port-status>) what)
  19. "Get a specific field from a port-status."
  20. (foreign-slot-value (ptr status) port-status-struct what))
  21. (defmethod port-status-has-send-rights? ((status <port-status>))
  22. "Return T if the port-status has send rights."
  23. (port-status-get status 'has-send-rights))
  24. (defmethod port-status-has-port-deleted-notification? ((status <port-status>))
  25. "Return T if the port from port-status has requested a port-deleted notification."
  26. (port-status-get status 'port-deleted-notification-requested))
  27. (defmethod port-status-has-no-senders-notification-p ((status <port-status>))
  28. "Return T if the port from port-status has requested a no-senders notification."
  29. (port-status-get status 'no-senders-notification-requested))
  30. (defmethod port-status-get-set ((status <port-status>))
  31. "Get the port-set field."
  32. (port-status-get status 'port-set))
  33. (defmethod port-status-get-mscount ((status <port-status>))
  34. "Get make send count from a status."
  35. (port-status-get status 'mscount))
  36. (defmethod port-status-get-queue-limit ((status <port-status>))
  37. "Get queue limit from a port status."
  38. (port-status-get status 'queue-limit))
  39. (defmethod port-status-get-msgcount ((status <port-status>))
  40. "Get msgcount field from status."
  41. (port-status-get status 'msgcount))
  42. (defmethod port-status-get-so-rights ((status <port-status>))
  43. "Get send once rights from a port status."
  44. (port-status-get status 'so-rights))
  45. (defun make-port-status (ptr)
  46. "Creates a new port-status using ptr as the status structure."
  47. (let ((mem (foreign-alloc <port-status-struct>)))
  48. (memcpy mem ptr (foreign-type-size <port-status-struct>))
  49. (let ((obj (make-instance <port-status> :ptr mem)))
  50. (tg:finalize obj (lambda ()
  51. (foreign-free mem)))
  52. obj)))