BioDynaMo
v1.05.120-25dc9790
|
#include <copy_execution_context.h>
Public Member Functions | |
CopyExecutionContext (const std::shared_ptr< ThreadSafeAgentUidMap > &map, std::shared_ptr< std::vector< std::vector< Agent * >>> agents) | |
~CopyExecutionContext () override | |
void | SetupIterationAll (const std::vector< ExecutionContext * > &all_exec_ctxts) override |
void | TearDownAgentOpsAll (const std::vector< ExecutionContext * > &all_exec_ctxts) override |
void | Execute (Agent *agent, AgentHandle ah, const std::vector< Operation * > &operations) override |
Public Member Functions inherited from bdm::InPlaceExecutionContext | |
InPlaceExecutionContext (const std::shared_ptr< ThreadSafeAgentUidMap > &map) | |
~InPlaceExecutionContext () override | |
void | SetupIterationAll (const std::vector< ExecutionContext * > &all_exec_ctxts) override |
void | TearDownIterationAll (const std::vector< ExecutionContext * > &all_exec_ctxts) override |
void | SetupAgentOpsAll (const std::vector< ExecutionContext * > &all_exec_ctxts) override |
void | TearDownAgentOpsAll (const std::vector< ExecutionContext * > &all_exec_ctxts) override |
void | Execute (Agent *agent, AgentHandle ah, const std::vector< Operation * > &operations) override |
void | ForEachNeighbor (Functor< void, Agent * > &lambda, const Agent &query, void *criteria) override |
void | ForEachNeighbor (Functor< void, Agent *, real_t > &lambda, const Agent &query, real_t squared_radius) override |
void | ForEachNeighbor (Functor< void, Agent *, real_t > &lambda, const Real3 &query_position, real_t squared_radius) override |
void | AddAgent (Agent *new_agent) override |
Adds the agent to the simulation (threadsafe, takes ownership). Note that we avoid the use of smart pointers for the agents to avoid unnecessary overhead during construction of the agent (performance argument). usage example : More... | |
void | RemoveAgent (const AgentUid &uid) override |
Agent * | GetAgent (const AgentUid &uid) override |
const Agent * | GetConstAgent (const AgentUid &uid) override |
Public Member Functions inherited from bdm::ExecutionContext | |
virtual | ~ExecutionContext ()=default |
Static Public Member Functions | |
static void | Use (Simulation *sim) |
Use the CopyExecutionContext for simulation sim . More... | |
Protected Attributes | |
std::shared_ptr< std::vector< std::vector< Agent * > > > | agents_ |
Protected Attributes inherited from bdm::InPlaceExecutionContext | |
std::shared_ptr< ThreadSafeAgentUidMap > | new_agent_map_ |
Lookup table AgentUid -> AgentPointer for new created agents. More... | |
ThreadInfo * | tinfo_ |
std::vector< Agent * > | new_agents_ |
Pointer to new agents. More... | |
std::vector< AgentUid > | remove_ |
std::atomic_flag | mutex_ = ATOMIC_FLAG_INIT |
prevent race conditions for cached Agents More... | |
std::vector< std::pair< Agent *, real_t > > | neighbor_cache_ |
real_t | cached_squared_search_radius_ = 0.0 |
The radius that was used to cache neighbors in neighbor_cache_ More... | |
bool | cache_neighbors_ = false |
Cache the value of Param::cache_neighbors. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from bdm::InPlaceExecutionContext | |
bool | IsNeighborCacheValid (real_t query_squared_radius) const |
virtual void | AddAgentsToRm (const std::vector< ExecutionContext * > &all_exec_ctxts) |
virtual void | RemoveAgentsFromRm (const std::vector< ExecutionContext * > &all_exec_ctxts) |
This execution context derives from InPlaceExecutionContext
and replaces the logic when agent updates will be visible to other agents. The remaining implementation is the same as in InPlaceExecutionContext
. The CopyExecutionContext
creates and updates a copy of an agent. The changes to this copy are committed at the end of the iteration.
Thus, all agents see the same agent state if they read attributes from their neighbors. The value of the neighbor attributes will be from the last iteration.
NB: This execution context does not support neighbor modification, Param::ExecutionOrder::kForEachOpForEachAgent
, and agent filter Scheduler::SetAgentFilters
.
Definition at line 37 of file copy_execution_context.h.
|
explicit |
Definition at line 38 of file copy_execution_context.cc.
|
overridedefault |
|
overridevirtual |
Execute a series of operations on an agent in the order given in the argument
Implements bdm::ExecutionContext.
Definition at line 87 of file copy_execution_context.cc.
|
overridevirtual |
This function is called at the beginning of each iteration to setup all execution contexts. This function is not thread-safe. NB: Invalidates references and pointers to agents.
Implements bdm::ExecutionContext.
Definition at line 58 of file copy_execution_context.cc.
|
overridevirtual |
This function is called after all agent operations were executed.
This function is not thread-safe.
NB: Invalidates references and pointers to agents.
Implements bdm::ExecutionContext.
Definition at line 77 of file copy_execution_context.cc.
|
static |
Use the CopyExecutionContext for simulation sim
.
Definition at line 24 of file copy_execution_context.cc.
|
protected |
Pointer container for all agents shared between all CopyExecutionContext instances of a simulation.
Definition at line 60 of file copy_execution_context.h.