From 064bf4f03173681a319546317851488363ee5ad1 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Sun, 31 Dec 2017 22:12:53 -0600 Subject: [PATCH] Add functions to work with a `jupyter-channel's `recv-queue` --- jupyter-channels.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jupyter-channels.el b/jupyter-channels.el index 447acc7..977a4ce 100644 --- a/jupyter-channels.el +++ b/jupyter-channels.el @@ -111,6 +111,17 @@ A channel is alive if its socket property is bound to a (and (slot-boundp channel 'socket) (not (null (oref channel socket))))) +(cl-defmethod jupyter-channel-push-message ((channel jupyter-channel) msg) + (let ((ring (oref channel recv-queue))) + (ring-insert+extend ring msg 'grow))) + +(cl-defmethod jupyter-channel-get-message ((channel jupyter-channel)) + (unless (ring-empty-p (oref channel recv-queue)) + (ring-remove (oref channel recv-queue)))) + +(cl-defmethod jupyter-channel-messages-available-p ((channel jupyter-channel)) + (not (ring-empty-p (oref channel recv-queue)))) + (defclass jupyter-hb-channel () ((type :type keyword