wxMaxima
Loading...
Searching...
No Matches
MaximaInterruptChannel.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2026 Gunter Königsmann <wxMaxima@physikbuch.de>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// SPDX-License-Identifier: GPL-2.0+
21
26#ifndef MAXIMAINTERRUPTCHANNEL_H
27#define MAXIMAINTERRUPTCHANNEL_H
28
30#include <wx/event.h>
31#include <wx/socket.h>
32#include <memory>
33
54class MaximaInterruptChannel : public wxEvtHandler
55{
56public:
61 MaximaInterruptChannel(wxSocketBase *socket, const wxString &token);
62 ~MaximaInterruptChannel() override;
63
65 bool IsReady() const;
67 bool IsDead() const;
68
70 bool SendInterrupt();
71
72private:
73 void OnSocketEvent(wxSocketEvent &event);
74 void Close();
75
77 struct SocketDeleter {
78 void operator()(wxSocketBase *socket) const { socket->Destroy(); }
79 };
80 std::unique_ptr<wxSocketBase, SocketDeleter> m_socket;
81 InterruptChannelHandshake m_handshake;
82};
83
84#endif // MAXIMAINTERRUPTCHANNEL_H
Declares InterruptChannelHandshake, which decides whether a connection may interrupt Maxima.
Checks the first line a would-be interrupt channel sends.
Definition: InterruptChannelHandshake.h:46
A second connection from Maxima's Lisp that interrupts its computation.
Definition: MaximaInterruptChannel.h:55
bool IsDead() const
True once the connection failed the handshake or was closed.
Definition: MaximaInterruptChannel.cpp:58
bool IsReady() const
True once the connection has proved it comes from our Maxima, and while it lasts.
Definition: MaximaInterruptChannel.cpp:53
bool SendInterrupt()
Asks Maxima to interrupt its computation. Returns false if that isn't possible.
Definition: MaximaInterruptChannel.cpp:103