trick/trick_source/sim_services/VariableServer/VariableServer_freeze_init.cpp
Jacqueline Deans c2e42f4ef4 Refactor and test Variable Server.
- Split VariableServerThread into VariableServerSession and VariableReference classes
- Use C++ streams for data handling
- Unit tests
2023-06-26 12:23:58 -05:00

35 lines
1018 B
C++

#include <iostream>
#include <sys/time.h>
#include "trick/VariableServer.hh"
#include "trick/variable_server_proto.h"
#include "trick/variable_server_sync_types.h"
#include "trick/TrickConstant.hh"
int Trick::VariableServer::freeze_init() {
long long next_call_tics ;
VariableServerSession * session ;
std::map < pthread_t , VariableServerSession * >::iterator it ;
next_call_tics = TRICK_MAX_LONG_LONG ;
pthread_mutex_lock(&map_mutex) ;
for ( it = var_server_sessions.begin() ; it != var_server_sessions.end() ; it++ ) {
session = (*it).second ;
session->freeze_init() ;
if ( session->get_freeze_next_tics() < next_call_tics ) {
next_call_tics = session->get_freeze_next_tics() ;
}
}
pthread_mutex_unlock(&map_mutex) ;
//reschedule the current job. TODO: a call needs to be created to do this the OO way
if ( copy_data_freeze_job != NULL ) {
copy_data_freeze_job->next_tics = next_call_tics ;
}
return(0) ;
}