A graph thread is a concrete derived class of thread that owns a node graph and that can receive messages, in addition to sending them.
More...
#include <graph_thread.h>
Inherits thread.
A graph thread is a concrete derived class of thread that owns a node graph and that can receive messages, in addition to sending them.
The node graph of a graph_thread exists in its worker thread. It can be provided in one of 2 ways:
#### Object Diagram #
Class Diagram
◆ graph_thread() [1/2]
| cppgraph::graph_thread::graph_thread |
( |
| ) |
|
|
protected |
Constructor.
An O/S thread is constructed and started. It enters a loop receiving and sending messages. While waiting for messages, the thread sleeps. The thread's graph must be supplied by posting a set_root_message to the thread.
◆ graph_thread() [2/2]
| cppgraph::graph_thread::graph_thread |
( |
node_handle const & |
h_root | ) |
|
|
protected |
Constructor.
An O/S thread is constructed and started. It enters a loop receiving and sending messages. While waiting for messages, the thread sleeps.
- Parameters
-
| h_root | The node graph rooted at this node is assigned as the worker thread's node graph. |
◆ get_root()
Returns the worker thread's root node.
Callable only from this graph_node's worker thread.
- Parameters
-
| error_action_type | The action to take if the graph is nullptr. |
- Exceptions
-
- Returns
- A handle to the worker thread's root node.
◆ get_this_thread()
Returns a pointer to the current worker thread's graph_thread owner.
Callable only from the worker thread owned by a graph_thread.
- Parameters
-
| error_action_type | The action to take if this function is not called from a worker thread owned by a graph_thread. |
- Returns
- A pointer to the
graph_thread instance that owns the current worker thread, or nullptr if this function was not called from a worker thread owned by a graph_thread.
- Exceptions
-
◆ on_end_thread_message()
[auto-generated] Handler for messages of type cppgraph :: end_thread_message .
- Parameters
-
| h_message | Message to handle. |
◆ on_nodes_request_message()
[auto-generated] Handler for messages of type cppgraph :: nodes_request_message .
- Parameters
-
| h_message | Message to handle. |
◆ on_set_root_message()
[auto-generated] Handler for messages of type cppgraph :: set_root_message .
- Parameters
-
| h_message | Message to handle. |
◆ post_end_message()
| void cppgraph::graph_thread::post_end_message |
( |
| ) |
|
Appends an end_thread_message to the worker thread's message queue.
When the worker thread pulls the message from its queue, it exits its message loop and terminates. This function may be called from any thread.
Callable only from the owner thread.
- See also
thread::request_end().
◆ set_root()
| void cppgraph::graph_thread::set_root |
( |
node_handle const & |
h_root | ) |
|
Sets the worker thread's root node.
Callable from any thread.
- Parameters
-
| h_root | Specifies the node to set as the current graph thread's root. |
- Exceptions
-
| exception | h_root is nullptr. |
- See also
get_root().
The documentation for this struct was generated from the following files:
- c:/cppgraph/lib/cppgraph/graph/threading/graph_thread.h
- c:/cppgraph/lib/cppgraph/graph/threading/graph_thread.cpp