|
GCSIM
|
local memory of a thread. More...
#include <thread-local-stack.hpp>
Public Member Functions | |
| thread_local_stack () | |
| creates the instance of the thread_local_stack. | |
| thread_local_stack (size_t hash_map_capacity) | |
| creates the instance of the thread_local_stack. | |
| ~thread_local_stack () | |
| deletes the thread_local_stack. | |
| thread_local_stack (const thread_local_stack &)=delete | |
| deleted copy constructor. | |
| thread_local_stack & | operator= (const thread_local_stack &)=delete |
| deleted assignment operator. | |
| thread_local_stack (thread_local_stack &&other) noexcept | |
| constructs the thread_local_stack instance from an existing one. | |
| thread_local_stack & | operator= (thread_local_stack &&other) noexcept |
| constructs new thread_local_stack by assigning it an existing one. | |
| void | init (std::string variable_name, header *heap_ptr=nullptr) |
| initializes new variable. | |
| void | reassign_ref (const std::string &variable_name, header *new_ref_to) |
| assigns new value to a variable. | |
| void | remove_ref (const std::string &variable_name) |
| removes the reference to a value on the heap. | |
| void | push_scope () noexcept |
| simulates entering new scope. | |
| void | pop_scope (bool destr=false) |
| simulates exiting scope. | |
| virtual void | accept (gc_visitor &visitor) noexcept override |
| accepts the gc visitor. | |
Public Member Functions inherited from root_set_base | |
| virtual | ~root_set_base ()=default |
| deletes the root_set_base object. | |
Private Member Functions | |
| indexed_stack< thread_local_stack_entry > & | get_thread_stack_unlocked () noexcept |
| getter for the thread_stack. | |
Private Attributes | |
| std::mutex | tls_mutex |
| used for tls synchronization. | |
| size_t | scope |
| id of the last pushed scope. | |
| indexed_stack< thread_local_stack_entry > | thread_stack |
| stack of initialized variables. | |
| hash_map< std::string, size_t > | var_to_idx |
| mapping the variable name to its index inside of the thread_stack. | |
Friends | |
| class | garbage_collector |
| allowing gc to access getter for the variable. | |
local memory of a thread.
| thread_local_stack::thread_local_stack | ( | ) |
creates the instance of the thread_local_stack.
scope defaults to 1.
| thread_local_stack::thread_local_stack | ( | size_t | hash_map_capacity | ) |
creates the instance of the thread_local_stack.
| hash_map_capacity | - number of buckets in the hash_map. |
scope defaults to 1.
| thread_local_stack::~thread_local_stack | ( | ) |
deletes the thread_local_stack.
frees final scope if not freed manually.
|
delete |
deleted copy constructor.
|
noexcept |
constructs the thread_local_stack instance from an existing one.
| other | - rvalue of the existing thread_local_stack. |
moves the ownership of the scope, thread_stack and var_to_idx map from other to this.
|
overridevirtualnoexcept |
accepts the gc visitor.
| visitor | - reference to a gc visitor. Calls marking on the gc visitor for thread-local elements. |
Implements root_set_base.
|
privatenoexcept |
getter for the thread_stack.
| void thread_local_stack::init | ( | std::string | variable_name, |
| header * | heap_ptr = nullptr |
||
| ) |
initializes new variable.
| variable_name | - name of the variable. |
| heap_ptr | - pointer to the value of the variable on the heap. |
| std::invalid_argument | when variable already exists. |
|
delete |
deleted assignment operator.
|
noexcept |
constructs new thread_local_stack by assigning it an existing one.
| other | - rvalue of the existing thread_local_stack. |
moves the ownership of the scope, thread_stack and var_to_idx map from other to this.
| void thread_local_stack::pop_scope | ( | bool | destr = false | ) |
simulates exiting scope.
| destr | - flag if pop_scope is called by destructor, defaults to false. |
|
noexcept |
simulates entering new scope.
| void thread_local_stack::reassign_ref | ( | const std::string & | variable_name, |
| header * | new_ref_to | ||
| ) |
assigns new value to a variable.
| variable_name | - name of the variable. |
| new_ref_to | - pointer to a new value on the heap. |
| std::invalid_argument | when variable_name is not previously initialized. |
| void thread_local_stack::remove_ref | ( | const std::string & | variable_name | ) |
removes the reference to a value on the heap.
| variable_name | - name of the variable. |
| std::invalid_argument | when variable_name is not previously initialized. |
|
friend |
allowing gc to access getter for the variable.
|
private |
id of the last pushed scope.
|
private |
stack of initialized variables.
|
mutableprivate |
used for tls synchronization.
|
private |
mapping the variable name to its index inside of the thread_stack.