Last active
September 23, 2015 19:43
-
-
Save gogo40/b2ad5d1d5143a77fc70e to your computer and use it in GitHub Desktop.
An example using the remote values api
This file contains hidden or 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
#include "common/values.h" | |
#include "clients/client.h" | |
struct MyContext { | |
std::string filename; | |
void execute(Response& r) { save_response_on_file(filename, r); } | |
}; | |
void execute_a_complex_task() { | |
//create a node connection | |
ar2gems_hpc::client::Client node("hydra01"); | |
bool ok = node.connect(); | |
if (!ok) { return; } | |
... | |
//Send 4 values to hydra01 | |
node.send_values("myHugeGrid", "myProperty", | |
{{1, 2}, {10, 11}}, | |
{1, 2.7, 3.4, 5.6}); | |
... | |
MyContext context{ "output.txt" }; | |
auto callback = [&context](Response& r){ | |
context.execute(r); | |
}; | |
node.execute("doAComplexTask", callback); | |
... | |
// Get 200 values from remote grid | |
common::Values some_result = node.get_values( | |
"someGrid", "someProperty", | |
{{1, 100}, {201, 300}}); | |
... | |
double a = 2.3, b = 3.7; | |
common::IntervalCallback callback2 = [&a, &b](common::Values& v, int idx, int offset) { | |
if (idx % 3 == 0) v[idx - offset] = a; | |
else v[idx - offset] = b; | |
set_property("my_grid", "my_prop", idx, v[idx - offset]); | |
}; | |
common::IntervalValue(200, 500, some_result).execute_for_each(callback2); | |
... | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment