Cadabra
Computer algebra system for field theory problems
|
Base class which talks to the server and sends Action objects back to the DocumentThread.
ComputeThread is the base class which takes care of doing actual computations with the cells in a document. It handles talking to the server backend. It knows how to pass cells to the server and ask them to be executed. Results are reported back to the GUI by putting ActionBase objects onto its todo stack. ComputeThread never directly modifies the document tree.
#include <ComputeThread.hh>
Public Member Functions | |
ComputeThread () | |
If the ComputeThread is constructed with a null pointer to the gui, there will be no gui updates, just DTree updates. More... | |
ComputeThread (const ComputeThread &)=delete | |
~ComputeThread () | |
void | set_master (GUIBase *, DocumentThread *) |
Determine the objects that this compute thread should be talking to. More... | |
void | run () |
Main entry point, which will connect to the server and then start an event loop to handle communication with the server. More... | |
void | execute_cell (DTree::iterator) |
In order to execute code on the server, call the following from the GUI thread. More... | |
void | stop () |
Stop the current cell execution on the server and remove all other cells from the run queue as well. More... | |
void | restart_kernel () |
Restart the kernel. More... | |
int | number_of_cells_executing (void) const |
void | terminate () |
Terminate the compute thread, in preparation for shutting down the client altogether. More... | |
Private Member Functions | |
void | init () |
void | try_connect () |
void | try_spawn_server () |
void | on_open (websocketpp::connection_hdl hdl) |
void | on_fail (websocketpp::connection_hdl hdl) |
void | on_close (websocketpp::connection_hdl hdl) |
void | on_message (websocketpp::connection_hdl hdl, message_ptr msg) |
void | cell_finished_running (DataCell::id_t) |
void | all_cells_nonrunning () |
Set all cells to be non-running (e.g. More... | |
Private Attributes | |
GUIBase * | gui |
DocumentThread * | docthread |
std::thread::id | gui_thread_id |
std::map< DataCell::id_t, DTree::iterator > | running_cells |
WSClient | wsclient |
bool | connection_is_open |
bool | restarting_kernel |
WSClient::connection_ptr | connection |
websocketpp::connection_hdl | our_connection_hdl |
Glib::Pid | server_pid |
int | server_stdout |
int | server_stderr |
unsigned short | port |
ComputeThread::ComputeThread | ( | ) |
If the ComputeThread is constructed with a null pointer to the gui, there will be no gui updates, just DTree updates.
|
delete |
ComputeThread::~ComputeThread | ( | ) |
|
private |
Set all cells to be non-running (e.g.
after a kernel failure) and report the status of each cell to the GUI.
|
private |
void ComputeThread::execute_cell | ( | DTree::iterator | it | ) |
In order to execute code on the server, call the following from the GUI thread.
This method returns as soon as the request has been put on the network queue. If no communication with the server is necessary, this returns immediately. The ComputeThread will report the result of the computation/processing by adding actions to the DocumentThread owned pending_actions stack, by calling queue_action. It will never modify the cell directly, and will also never modify any other cells in the document tree.
|
private |
int ComputeThread::number_of_cells_executing | ( | void | ) | const |
|
private |
|
private |
|
private |
|
private |
void ComputeThread::restart_kernel | ( | ) |
Restart the kernel.
void ComputeThread::run | ( | ) |
Main entry point, which will connect to the server and then start an event loop to handle communication with the server.
Only terminates when the connection drops, so run your GUI on a different thread.
void ComputeThread::set_master | ( | GUIBase * | b, |
DocumentThread * | d | ||
) |
Determine the objects that this compute thread should be talking to.
void ComputeThread::stop | ( | ) |
Stop the current cell execution on the server and remove all other cells from the run queue as well.
void ComputeThread::terminate | ( | ) |
Terminate the compute thread, in preparation for shutting down the client altogether.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |