Commit 142f87ed authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

added many example

parent 32e87f50
......@@ -56,3 +56,4 @@ xpkg_import_module (margo REQUIRED margo)
add_subdirectory (src)
add_subdirectory (test)
add_subdirectory (examples)
add_executable(00_init_server server.cpp)
target_link_libraries(00_init_server thallium)
add_executable(00_init_client client.cpp)
target_link_libraries(00_init_client thallium)
#include <thallium.hpp>
namespace tl = thallium;
int main(int argc, char** argv) {
tl::engine myEngine("bmi+tcp", THALLIUM_CLIENT_MODE);
return 0;
}
#include <iostream>
#include <thallium.hpp>
namespace tl = thallium;
int main(int argc, char** argv) {
tl::engine myEngine("bmi+tcp://127.0.0.1:1234", THALLIUM_SERVER_MODE);
std::cout << "Server running at address " << myEngine.self() << std::endl;
return 0;
}
add_executable(01_hello_server server.cpp)
target_link_libraries(01_hello_server thallium)
add_executable(01_hello_client client.cpp)
target_link_libraries(01_hello_client thallium)
#include <thallium.hpp>
namespace tl = thallium;
int main(int argc, char** argv) {
tl::engine myEngine("bmi+tcp", THALLIUM_CLIENT_MODE);
tl::remote_procedure hello = myEngine.define("hello").ignore_response();
tl::endpoint server = myEngine.lookup("bmi+tcp://127.0.0.1:1234");
hello.on(server)();
return 0;
}
#include <iostream>
#include <thallium.hpp>
namespace tl = thallium;
void hello(const tl::request& req) {
std::cout << "Hello World!" << std::endl;
}
int main(int argc, char** argv) {
tl::engine myEngine("bmi+tcp://127.0.0.1:1234", THALLIUM_SERVER_MODE);
myEngine.define("hello", hello).ignore_response();
return 0;
}
add_executable(02_sum_server server.cpp)
target_link_libraries(02_sum_server thallium)
add_executable(02_sum_client client.cpp)
target_link_libraries(02_sum_client thallium)
#include <iostream>
#include <thallium.hpp>
namespace tl = thallium;
int main(int argc, char** argv) {
tl::engine myEngine("bmi+tcp", THALLIUM_CLIENT_MODE);
tl::remote_procedure sum = myEngine.define("sum");
tl::endpoint server = myEngine.lookup("bmi+tcp://127.0.0.1:1234");
int ret = sum.on(server)(42,63);
std::cout << "Server answered " << ret << std::endl;
return 0;
}
#include <iostream>
#include <thallium.hpp>
namespace tl = thallium;
void sum(const tl::request& req, int x, int y) {
std::cout << "Computing " << x << "+" << y << std::endl;
req.respond(x+y);
}
int main(int argc, char** argv) {
tl::engine myEngine("bmi+tcp://127.0.0.1:1234", THALLIUM_SERVER_MODE);
myEngine.define("sum", sum);
return 0;
}
add_executable(03_lambda_server server.cpp)
target_link_libraries(03_lambda_server thallium)
add_executable(03_lambda_client client.cpp)
target_link_libraries(03_lambda_client thallium)
#include <iostream>
#include <thallium.hpp>
namespace tl = thallium;
int main(int argc, char** argv) {
tl::engine myEngine("bmi+tcp", THALLIUM_CLIENT_MODE);
tl::remote_procedure sum = myEngine.define("sum");
tl::endpoint server = myEngine.lookup("bmi+tcp://127.0.0.1:1234");
int ret = sum.on(server)(42,63);
std::cout << "Server answered " << ret << std::endl;
return 0;
}
#include <iostream>
#include <thallium.hpp>
namespace tl = thallium;
int main(int argc, char** argv) {
tl::engine myEngine("bmi+tcp://127.0.0.1:1234", THALLIUM_SERVER_MODE);
std::function<void(const tl::request&, int, int)> sum =
[](const tl::request& req, int x, int y) {
std::cout << "Computing " << x << "+" << y << std::endl;
req.respond(x+y);
};
myEngine.define("sum", sum);
return 0;
}
add_executable(04_stop_server server.cpp)
target_link_libraries(04_stop_server thallium)
add_executable(04_stop_client client.cpp)
target_link_libraries(04_stop_client thallium)
#include <iostream>
#include <thallium.hpp>
namespace tl = thallium;
int main(int argc, char** argv) {
tl::engine myEngine("bmi+tcp", THALLIUM_CLIENT_MODE);
tl::remote_procedure sum = myEngine.define("sum");
tl::endpoint server = myEngine.lookup("bmi+tcp://127.0.0.1:1234");
int ret = sum.on(server)(42,63);
std::cout << "Server answered " << ret << std::endl;
return 0;
}
#include <iostream>
#include <thallium.hpp>
namespace tl = thallium;
int main(int argc, char** argv) {
tl::engine myEngine("bmi+tcp://127.0.0.1:1234", THALLIUM_SERVER_MODE);
std::function<void(const tl::request&, int, int)> sum =
[&myEngine](const tl::request& req, int x, int y) {
std::cout << "Computing " << x << "+" << y << std::endl;
req.respond(x+y);
myEngine.finalize();
};
myEngine.define("sum", sum);
return 0;
}
add_executable(05_stl_server server.cpp)
target_link_libraries(05_stl_server thallium)
add_executable(05_stl_client client.cpp)
target_link_libraries(05_stl_client thallium)
#include <string>
#include <thallium.hpp>
#include <thallium/serialization/stl/string.hpp>
namespace tl = thallium;
int main(int argc, char** argv) {
tl::engine myEngine("bmi+tcp", THALLIUM_CLIENT_MODE);
tl::remote_procedure hello = myEngine.define("hello").ignore_response();
tl::endpoint server = myEngine.lookup("bmi+tcp://127.0.0.1:1234");
std::string name = "Matthieu";
hello.on(server)(name);
return 0;
}
#include <string>
#include <iostream>
#include <thallium.hpp>
#include <thallium/serialization/stl/string.hpp>
namespace tl = thallium;
void hello(const tl::request& req, const std::string& name) {
std::cout << "Hello " << name << std::endl;
}
int main(int argc, char** argv) {
tl::engine myEngine("bmi+tcp://127.0.0.1:1234", THALLIUM_SERVER_MODE);
myEngine.define("hello", hello).ignore_response();
return 0;
}
add_executable(06_custom_server server.cpp)
target_link_libraries(06_custom_server thallium)
add_executable(06_custom_client client.cpp)
target_link_libraries(06_custom_client thallium)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment