diff --git a/include/trick/ExternalApplication.hh b/include/trick/ExternalApplication.hh index 3e93930e..3b87d925 100644 --- a/include/trick/ExternalApplication.hh +++ b/include/trick/ExternalApplication.hh @@ -295,13 +295,6 @@ namespace Trick { /** Command to execute when starting this application. */ std::string command; - /** Pointer to alloc'd command c str for use with external application c_intf */ - char * command_c_str; - - /** alloc'd addresses to be deallocated during app destruction (currently only - used by command_c_str) */ - std::vector allocations; - private: /** Prevent SWIG from trying to invoke operator= on ostringstream. */ diff --git a/trick_source/java/src/main/java/trick/sie/utils/SearchPanel.java b/trick_source/java/src/main/java/trick/sie/utils/SearchPanel.java index 34c7de17..2fe40178 100644 --- a/trick_source/java/src/main/java/trick/sie/utils/SearchPanel.java +++ b/trick_source/java/src/main/java/trick/sie/utils/SearchPanel.java @@ -115,7 +115,8 @@ public class SearchPanel extends JXPanel { listModel.clear(); searcher.search(textField.getText().trim(), caseSensitiveCheckBox.isSelected(), - regularExpressionCheckBox.isSelected()); + regularExpressionCheckBox.isSelected(), + greedySearchCheckBox.isSelected()); if (searcher.elementCount == 0) { progressBar.setIndeterminate(true); } @@ -136,6 +137,12 @@ public class SearchPanel extends JXPanel { setToolTipText("Toggle regular expression searching."); }}; + /** toggles case-insensitive searching */ + JCheckBox greedySearchCheckBox = new JCheckBox("Greedy Search") {{ + setName("greedySearchCheckBox"); + setToolTipText("Toggle multi-threaded search (Warning: may cause overruns)."); + }}; + /** search results list model */ EfficientListModel listModel = new EfficientListModel(); @@ -227,6 +234,7 @@ public class SearchPanel extends JXPanel { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); add(caseSensitiveCheckBox); add(regularExpressionCheckBox); + add(greedySearchCheckBox); }}); }}, constraints); @@ -306,6 +314,7 @@ public class SearchPanel extends JXPanel { textField.setEnabled(enabled); caseSensitiveCheckBox.setEnabled(enabled); regularExpressionCheckBox.setEnabled(enabled); + greedySearchCheckBox.setEnabled(enabled); list.setEnabled(enabled); list.setComponentPopupMenu(enabled ? popupMenu : null); } diff --git a/trick_source/java/src/main/java/trick/sie/utils/Searcher.java b/trick_source/java/src/main/java/trick/sie/utils/Searcher.java index 04a2245c..aaf20e1b 100644 --- a/trick_source/java/src/main/java/trick/sie/utils/Searcher.java +++ b/trick_source/java/src/main/java/trick/sie/utils/Searcher.java @@ -89,9 +89,10 @@ public class Searcher { * @param targetText the text for which to search * @param caseSensitive enables case sensitive searching * @param regularExpression enables regular expression searching + * @param greedSearch enabled multi-threaded search */ public void search(final String targetText, final boolean caseSensitive, - final boolean regularExpression) { + final boolean regularExpression, final boolean greedySearch) { final SearchFunction searchFunction = regularExpression ? @@ -124,7 +125,11 @@ public class Searcher { cancelSearch(); count = 0; - threads = Runtime.getRuntime().availableProcessors(); + if (greedySearch) { + threads = Runtime.getRuntime().availableProcessors(); + } else { + threads = 1; + } propertyChangeListener.propertyChange(new PropertyChangeEvent(this, "progress", 0, 0)); final ConcurrentLinkedQueue roots = new ConcurrentLinkedQueue(rootTemplates); executorService = Executors.newFixedThreadPool(threads); diff --git a/trick_source/sim_services/ExternalApplications/ExternalApplication.cpp b/trick_source/sim_services/ExternalApplications/ExternalApplication.cpp index ac377799..1e540e92 100644 --- a/trick_source/sim_services/ExternalApplications/ExternalApplication.cpp +++ b/trick_source/sim_services/ExternalApplications/ExternalApplication.cpp @@ -19,25 +19,13 @@ Trick::ExternalApplication::ExternalApplication() : host_source = port_source = AUTO; cycle_period_set = minimum_cycle_period_set = disconnect_behavior_set = height_set = width_set = x_set = y_set = auto_reconnect_set = false; - - // c_intf uses char *, we manage the memory here in external application - command_c_str = (char*)trick_MM->declare_var("char", (command.size() + 1) ); - strcpy(command_c_str, command.c_str()); - allocations.push_back(command_c_str); } Trick::ExternalApplication::~ExternalApplication() { - for(std::vector::iterator it = allocations.begin(); it != allocations.end(); ++it) { - trick_MM->delete_var( (void*)*it ); - } - allocations.clear(); } void Trick::ExternalApplication::set_startup_command(std::string in_command) { command = in_command; - command_c_str = (char*)trick_MM->declare_var("char", (command.size() + 1) ); - strcpy(command_c_str, command.c_str()); - allocations.push_back((command_c_str)); } std::string Trick::ExternalApplication::get_startup_command() { @@ -45,7 +33,7 @@ std::string Trick::ExternalApplication::get_startup_command() { } const char * Trick::ExternalApplication::get_startup_command_c_str() { - return command_c_str; + return command.c_str(); } void Trick::ExternalApplication::add_arguments(std::string args) { diff --git a/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp b/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp index 4bde1c45..008485bf 100644 --- a/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp +++ b/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp @@ -37,19 +37,18 @@ int Trick::MemoryManager::delete_var(void* address ) { MemoryManager allocated it. */ if ( alloc_info->stcl == TRICK_LOCAL ) { - if ( alloc_info->alloc_type == TRICK_ALLOC_MALLOC ) { + // The destructor that we just called MAY have deleted addresses + // that are already planned for deletion, say during reset_memory. + // So, keep a record of what we've recently deleted so we don't + // to warn that we can't find it, when reset_memory also tries to + // delete that same address. Same for TRICK_ALLOC_NEW block + deleted_addr_list.push_back(address); + if ( alloc_info->alloc_type == TRICK_ALLOC_MALLOC ) { // This will call a destructor ONLY if alloc_info->type is TRICK_STRUCTURED. // Otherwise it does nothing. io_src_destruct_class( alloc_info ); - // The destructor that we just called MAY have deleted addresses - // that are already planned for deletion, say during reset_memory. - // So, keep a record of what we've recently deleted so we don't - // to warn that we can't find it, when reset_memory also tries to - // delete that same address. - deleted_addr_list.push_back(address); - free( address); } else if ( alloc_info->alloc_type == TRICK_ALLOC_NEW ) { io_src_delete_class( alloc_info ); diff --git a/trick_source/sim_services/ScheduledJobQueue/ScheduledJobQueue.cpp b/trick_source/sim_services/ScheduledJobQueue/ScheduledJobQueue.cpp index 85824cf8..e604a864 100644 --- a/trick_source/sim_services/ScheduledJobQueue/ScheduledJobQueue.cpp +++ b/trick_source/sim_services/ScheduledJobQueue/ScheduledJobQueue.cpp @@ -91,6 +91,11 @@ int Trick::ScheduledJobQueue::push( JobData * new_job ) { /* Increment the size of the queue */ list_size++ ; + + int new_job_index = (insert_pt - list) / sizeof(JobData**); + if(new_job_index < curr_index) { + curr_index++; + } return(0) ; diff --git a/trick_source/sim_services/VariableServer/VariableServerListenThread.cpp b/trick_source/sim_services/VariableServer/VariableServerListenThread.cpp index 643df11a..0dbc1139 100644 --- a/trick_source/sim_services/VariableServer/VariableServerListenThread.cpp +++ b/trick_source/sim_services/VariableServer/VariableServerListenThread.cpp @@ -112,21 +112,24 @@ int Trick::VariableServerListenThread::init_listen_device() { // Called from init jobs int Trick::VariableServerListenThread::check_and_move_listen_device() { - int ret ; + int ret = 0; if (_user_requested_address) { /* The user has requested a different source address or port in the input file */ _listener->disconnect(); ret = _listener->initialize(_requested_source_address, _requested_port); - _requested_port = _listener->getPort(); - _requested_source_address = _listener->getHostname(); + if (ret != 0) { message_publish(MSG_ERROR, "ERROR: Could not establish variable server source_address %s: port %d. Aborting.\n", _requested_source_address.c_str(), _requested_port); - return -1 ; + + ret = -1; } + + _requested_port = _listener->getPort(); + _requested_source_address = _listener->getHostname(); } - return 0 ; + return ret ; } void * Trick::VariableServerListenThread::thread_body() { @@ -248,7 +251,10 @@ int Trick::VariableServerListenThread::restart() { message_publish(MSG_INFO, "restart variable server message port = %d\n", _listener->getPort()); } - initializeMulticast(); + // Don't initialize the multicast group if it's already initialized + if (!_multicast->isInitialized()) { + initializeMulticast(); + } return 0 ; }