BioDynaMo  v1.03.58-27764645
Public Member Functions | Private Member Functions | Private Attributes | List of all members
bdm::AgentUidGenerator Class Reference

This class generates unique ids for agents. More...

#include <agent_uid_generator.h>

Collaboration diagram for bdm::AgentUidGenerator:

Public Member Functions

 AgentUidGenerator (const AgentUidGenerator &)=delete
 AgentUidGenerator ()
AgentUid GenerateUid ()
AgentUid::Index_t GetHighestIndex () const
 Thread-safe. More...
void ReuseAgentUid (const AgentUid &uid)
void Update ()

Private Member Functions

 BDM_CLASS_DEF_NV (AgentUidGenerator, 1)

Private Attributes

std::atomic< typename AgentUid::Index_tcounter_
AgentUid::Index_t root_counter_
SharedData< std::vector< AgentUid > > tl_uids_
 Thread local vector of AgentUids that can be reused. More...
ThreadInfotinfo_ = nullptr

Detailed Description

This class generates unique ids for agents.

Definition at line 33 of file agent_uid_generator.h.

Constructor & Destructor Documentation

◆ AgentUidGenerator() [1/2]

bdm::AgentUidGenerator::AgentUidGenerator ( const AgentUidGenerator )

◆ AgentUidGenerator() [2/2]

bdm::AgentUidGenerator::AgentUidGenerator ( )

Definition at line 36 of file agent_uid_generator.h.

Member Function Documentation


bdm::AgentUidGenerator::BDM_CLASS_DEF_NV ( AgentUidGenerator  ,

◆ GenerateUid()

AgentUid bdm::AgentUidGenerator::GenerateUid ( )

Generates AgentUid with increasing index. In defragmentation mode it reuses index values from removed agents and increments the reused field. Thread-safe.

Definition at line 44 of file agent_uid_generator.h.

◆ GetHighestIndex()

AgentUid::Index_t bdm::AgentUidGenerator::GetHighestIndex ( ) const


Definition at line 56 of file agent_uid_generator.h.

◆ ReuseAgentUid()

void bdm::AgentUidGenerator::ReuseAgentUid ( const AgentUid uid)

Adds AgentUid that can be reused after AgentUid::reused_ is incremented. Thread-safe.

Definition at line 60 of file agent_uid_generator.h.

◆ Update()

void bdm::AgentUidGenerator::Update ( )

Resizes internal data structures to the number of threads. NB: If Update is called, calls to GenerateUid or ReuseAgentUid are not allowed!

Definition at line 67 of file agent_uid_generator.h.

Member Data Documentation

◆ counter_

std::atomic<typename AgentUid::Index_t> bdm::AgentUidGenerator::counter_

Definition at line 70 of file agent_uid_generator.h.

◆ root_counter_

AgentUid::Index_t bdm::AgentUidGenerator::root_counter_

ROOT can't persist std::atomic. Therefore this additional helper variable is needed.

Definition at line 73 of file agent_uid_generator.h.

◆ tinfo_

ThreadInfo* bdm::AgentUidGenerator::tinfo_ = nullptr

Definition at line 77 of file agent_uid_generator.h.

◆ tl_uids_

SharedData<std::vector<AgentUid> > bdm::AgentUidGenerator::tl_uids_

Thread local vector of AgentUids that can be reused.

Definition at line 76 of file agent_uid_generator.h.

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