Merge branch 'nasa:master' into master

This commit is contained in:
M-Herr 2024-09-28 01:15:54 -05:00 committed by GitHub
commit 95230b06f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 42 additions and 37 deletions

View File

@ -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<char*> allocations;
private:
/** Prevent SWIG from trying to invoke operator= on ostringstream. */

View File

@ -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);
}

View File

@ -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<SieTemplate> roots = new ConcurrentLinkedQueue<SieTemplate>(rootTemplates);
executorService = Executors.newFixedThreadPool(threads);

View File

@ -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<char*>::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) {

View File

@ -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 );

View File

@ -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) ;

View File

@ -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 ;
}