53 desc(
"cl-device-name")
54 .help(
"The name of the CL device used by this worker"),
56 , reader(
desc(
"reader",
"thread_config"), this)
57 , writer(
desc(
"writer",
"thread_config"), this) {
73 desc(
"securities").help(
"The list of securities to process"), this)
74 , workers(
desc(
"workers",
"worker_config"), this) {
82 int main(
int argc,
char* argv[])
try {
88 std::vector<worker_config> v;
89 v.push_back(std::move(
worker_config().cl_device_name(
"Tahiti")));
93 config.
load_overrides(argc, argv,
"my_program.yaml",
"MY_PROGRAM_ROOT");
96 std::cout <<
"securities = [";
99 std::cout << sep << s;
104 for (
auto w : config.
workers()) {
105 std::cout <<
"worker." << cnt <<
".cl-device-name = " << w.cl_device_name()
112 std::cerr << ex.what() << std::endl;
114 }
catch (std::exception
const& ex) {
115 std::cerr <<
"standard exception raised: " << ex.what() << std::endl;
118 std::cerr <<
"unknown exception raised" << std::endl;
138 std::string msg(
"Unknown scheduling policy: ");
140 throw std::runtime_error(msg);
146 return sched_get_priority_min(policy);
149 return sched_get_priority_max(policy);
152 return (sched_get_priority_max(policy) + sched_get_priority_min(policy)) /
159 std::string msg(
"Invalid scheduling priority: ");
161 throw std::runtime_error(msg);
The main configuration class for this example program.
Base class for all configuration objects.
jb::config_attribute< worker_config, std::string > cl_device_name
A configuration class for a worker with two threads.
jb::config_attribute< thread_config, std::string > scheduler
config_object_constructors(thread_config)
int native_scheduling_policy() const
jb::config_attribute< program_config, std::vector< worker_config > > workers
A configuration class for threads.
void load_overrides(int &argc, char *argv[], std::string const &filename, char const *environment_variable_name)
Read the configuration file and load the overrides defined therein.
int native_priority() const
jb::config_attribute< worker_config, thread_config > writer
int main(int argc, char *argv[])
jb::config_attribute< thread_config, std::string > name
jb::config_attribute< worker_config, thread_config > reader
bool strtonum(std::string const &s, T &r)
Generic string to number conversion with validation.
A simple class to communicate the result of parsing the options.
static attribute_descriptor desc(std::string const &name)
Convenience function to create attribute descriptors with less typing.
jb::config_attribute< thread_config, std::string > priority
jb::config_attribute< program_config, std::vector< std::string > > securities
jb::config_attribute< thread_config, int > affinity