Last active
July 14, 2018 12:48
-
-
Save hkaiser/48c0b80e1d6dff9f14c378e7bf07b183 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// some header file | |
// Allow applications to add configuration settings if HPX_MAIN is set | |
std::vector<std::string> user_main_config( | |
std::vector<std::string> const& config); | |
// Make sure our configuration information is injected into the startup | |
// procedure | |
struct register_user_main_config | |
{ | |
register_user_main_config(); | |
static std::vector<std::string> (*prev_user_main_config_function)( | |
std::vector<std::string> const&) = nullptr; | |
}; | |
extern register_user_main_config cfg; | |
// some source file | |
std::vector<std::string> user_main_config( | |
std::vector<std::string> const& config) | |
{ | |
std::vector<std::string> cfg(config); | |
// rx jobs should run on at least two cores to avoid deadlocks | |
cfg.push_back("hpx.os_threads=2"); | |
// disable the aliasing of HPX's command line options | |
// (this allows for the short options as defined by Catch) | |
cfg.push_back("hpx.commandline.aliasing=0"); | |
// If there was another config function registered, call it | |
if (register_user_main_config::prev_user_main_config_function) | |
return register_user_main_config::prev_user_main_config_function(cfg); | |
return cfg; | |
} | |
// make sure user_main_config is registered | |
register_user_main_config cfg; | |
register_user_main_config::register_user_main_config() | |
{ | |
prev_user_main_config_function = | |
hpx_startup::user_main_config_function; | |
hpx_startup::user_main_config_function = &user_main_config; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment