Cadabra
Computer algebra system for field theory problems
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
cadabra::ComputeThread Class Reference

Description

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

GUIBasegui
 
DocumentThreaddocthread
 
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
 

Constructor & Destructor Documentation

ComputeThread::ComputeThread ( )

If the ComputeThread is constructed with a null pointer to the gui, there will be no gui updates, just DTree updates.

cadabra::ComputeThread::ComputeThread ( const ComputeThread )
delete
ComputeThread::~ComputeThread ( )

Member Function Documentation

void ComputeThread::all_cells_nonrunning ( )
private

Set all cells to be non-running (e.g.

after a kernel failure) and report the status of each cell to the GUI.

void ComputeThread::cell_finished_running ( DataCell::id_t  id)
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.

void ComputeThread::init ( )
private
int ComputeThread::number_of_cells_executing ( void  ) const
void ComputeThread::on_close ( websocketpp::connection_hdl  hdl)
private
void ComputeThread::on_fail ( websocketpp::connection_hdl  hdl)
private
void ComputeThread::on_message ( websocketpp::connection_hdl  hdl,
message_ptr  msg 
)
private
void ComputeThread::on_open ( websocketpp::connection_hdl  hdl)
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.

void ComputeThread::try_connect ( )
private
void ComputeThread::try_spawn_server ( )
private

Member Data Documentation

WSClient::connection_ptr cadabra::ComputeThread::connection
private
bool cadabra::ComputeThread::connection_is_open
private
DocumentThread* cadabra::ComputeThread::docthread
private
GUIBase* cadabra::ComputeThread::gui
private
std::thread::id cadabra::ComputeThread::gui_thread_id
private
websocketpp::connection_hdl cadabra::ComputeThread::our_connection_hdl
private
unsigned short cadabra::ComputeThread::port
private
bool cadabra::ComputeThread::restarting_kernel
private
std::map<DataCell::id_t, DTree::iterator> cadabra::ComputeThread::running_cells
private
Glib::Pid cadabra::ComputeThread::server_pid
private
int cadabra::ComputeThread::server_stderr
private
int cadabra::ComputeThread::server_stdout
private
WSClient cadabra::ComputeThread::wsclient
private

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