wxMaxima
Loading...
Searching...
No Matches
Data Structures | Public Member Functions
MaximaInterruptChannel Class Reference

A second connection from Maxima's Lisp that interrupts its computation. More...

#include <MaximaInterruptChannel.h>

Inheritance diagram for MaximaInterruptChannel:
[legend]
Collaboration diagram for MaximaInterruptChannel:
[legend]

Public Member Functions

 MaximaInterruptChannel (wxSocketBase *socket, const wxString &token)
 Takes ownership of socket, a connection wxSocketServer::Accept() returned.
 
bool IsReady () const
 True once the connection has proved it comes from our Maxima, and while it lasts.
 
bool IsDead () const
 True once the connection failed the handshake or was closed.
 
bool SendInterrupt ()
 Asks Maxima to interrupt its computation. Returns false if that isn't possible.
 

Detailed Description

A second connection from Maxima's Lisp that interrupts its computation.

Interrupting Maxima used to rely on the operating system: kill(SIGINT) on POSIX, and on MS Windows a shared-memory segment named after the Lisp's pid or, failing that, a console Ctrl+C. The Windows ways fail in ways a user can do nothing about (GH #2289): the pid may be unknown, the segment is only created if Maxima's signal thread was started, and wxmaxima.exe has no console.

So a Lisp that has threads opens a second connection to wxMaxima's server right after connecting (wx-open-interrupt-channel in wxMathML.lisp). A thread in the Lisp waits on it, and SendInterrupt() writing "interrupt" makes that thread interrupt the one evaluating Maxima's commands. A Lisp without threads never opens one; IsReady() then stays false and the caller falls back to the old ways.

The connection only counts after it has sent the secret wxMaxima gave Maxima (see InterruptChannelHandshake): anybody on this machine can connect to the server's port.

Constructor & Destructor Documentation

◆ MaximaInterruptChannel()

MaximaInterruptChannel::MaximaInterruptChannel ( wxSocketBase *  socket,
const wxString &  token 
)

Takes ownership of socket, a connection wxSocketServer::Accept() returned.

Parameters
tokenThe secret the connection has to send first.

The documentation for this class was generated from the following files: