Remove jupyter-hb-comm

* jupyter-channel-ioloop-comm.el
(jupyter-channel-ioloop-comm): Remove it from the super-class list.
Add a `hb` slot to compensate.
(jupyter-hb-beating-p, jupyter-hb-pause)
(jupyter-hb-unpause): Relocated from...

* jupyter-comm-layer.el: ...here.

* jupyter-client.el (jupyter-hb-beating-p, jupyter-hb-pause)
(jupyter-hb-unpause): Check for a `hb` slot instead of it.
This commit is contained in:
Nathaniel Nicandro 2020-04-22 19:20:30 -05:00
parent 93eeda42a6
commit 4164f13bdc
3 changed files with 16 additions and 22 deletions

View file

@ -152,9 +152,9 @@
(cl-defstruct jupyter-proxy-channel endpoint alive-p)
(defclass jupyter-channel-ioloop-comm (jupyter-ioloop-comm
jupyter-hb-comm
jupyter-comm-autostop)
((conn :type jupyter-connection)
(hb :type jupyter-channel)
(session :type jupyter-session)))
(cl-defmethod jupyter-comm-id ((comm jupyter-channel-ioloop-comm))
@ -166,7 +166,7 @@
(let ((conn (make-jupyter-async-connection
session (lambda (event) (jupyter-event-handler comm event)))))
(oset comm conn conn)
(oset comm hb (jupyter-connection-hb (oref comm conn)))))
(oset comm hb (jupyter-connection-hb conn))))
(cl-defmethod jupyter-comm-start ((comm jupyter-channel-ioloop-comm))
(jupyter-start (oref comm conn)))
@ -193,6 +193,17 @@
(cl-defmethod jupyter-start-channel ((comm jupyter-channel-ioloop-comm) channel)
(jupyter-start (oref comm conn) channel))
;;;; HB channel methods
(cl-defmethod jupyter-hb-beating-p ((comm jupyter-channel-ioloop-comm))
(jupyter-hb-beating-p (oref comm hb)))
(cl-defmethod jupyter-hb-pause ((comm jupyter-channel-ioloop-comm))
(jupyter-hb-pause (oref comm hb)))
(cl-defmethod jupyter-hb-unpause ((comm jupyter-channel-ioloop-comm))
(jupyter-hb-unpause (oref comm hb)))
(provide 'jupyter-channel-ioloop-comm)
;;; jupyter-channel-ioloop-comm.el ends here

View file

@ -624,16 +624,16 @@ back."
(jupyter-channel-alive-p (oref client kcomm) channel))
(cl-defmethod jupyter-hb-pause ((client jupyter-kernel-client))
(when (cl-typep (oref client kcomm) 'jupyter-hb-comm)
(when (slot-exists-p (oref client kcomm) 'hb)
(jupyter-hb-pause (oref client kcomm))))
(cl-defmethod jupyter-hb-unpause ((client jupyter-kernel-client))
(when (cl-typep (oref client kcomm) 'jupyter-hb-comm)
(when (slot-exists-p (oref client kcomm) 'hb)
(jupyter-hb-unpause (oref client kcomm))))
(cl-defmethod jupyter-hb-beating-p ((client jupyter-kernel-client))
"Is CLIENT still connected to its kernel?"
(or (null (cl-typep (oref client kcomm) 'jupyter-hb-comm))
(or (null (slot-exists-p (oref client kcomm) 'hb))
(jupyter-hb-beating-p (oref client kcomm))))
;;; Message callbacks

View file

@ -179,23 +179,6 @@ called if needed. This means that a call to
(zerop (length (oref comm handlers))))
(jupyter-comm-stop comm)))
;;; `jupyter-hb-comm'
;; If the communication layer can talk to a heartbeat channel, then it should
;; add this class as a parent class.
(defclass jupyter-hb-comm ()
((hb :type jupyter-hb-channel))
:abstract t)
(cl-defmethod jupyter-hb-beating-p ((comm jupyter-hb-comm))
(jupyter-hb-beating-p (oref comm hb)))
(cl-defmethod jupyter-hb-pause ((comm jupyter-hb-comm))
(jupyter-hb-pause (oref comm hb)))
(cl-defmethod jupyter-hb-unpause ((comm jupyter-hb-comm))
(jupyter-hb-unpause (oref comm hb)))
(provide 'jupyter-comm-layer)
;;; jupyter-comm-layer.el ends here