Commit b524a6c3 authored by Dominik Charousset's avatar Dominik Charousset

optional => maybe

parent a6d1df77
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
typename detail::tl_filter<arg_types, is_input_arg>::type; typename detail::tl_filter<arg_types, is_input_arg>::type;
using input_types = using input_types =
typename detail::tl_map<input_wrapped_types, extract_type>::type; typename detail::tl_map<input_wrapped_types, extract_type>::type;
using input_mapping = std::function<optional<message> (message&)>; using input_mapping = std::function<maybe<message> (message&)>;
using output_wrapped_types = using output_wrapped_types =
typename detail::tl_filter<arg_types, is_output_arg>::type; typename detail::tl_filter<arg_types, is_output_arg>::type;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <type_traits> #include <type_traits>
#include "caf/message.hpp" #include "caf/message.hpp"
#include "caf/optional.hpp" #include "caf/maybe.hpp"
namespace caf { namespace caf {
namespace opencl { namespace opencl {
...@@ -56,7 +56,7 @@ struct out { ...@@ -56,7 +56,7 @@ struct out {
out() { } out() { }
template <class F> template <class F>
out(F fun) { out(F fun) {
fun_ = [fun](message& msg) -> optional<size_t> { fun_ = [fun](message& msg) -> maybe<size_t> {
auto res = msg.apply(fun); auto res = msg.apply(fun);
size_t result; size_t result;
if (res) { if (res) {
...@@ -66,10 +66,10 @@ struct out { ...@@ -66,10 +66,10 @@ struct out {
return none; return none;
}; };
} }
optional<size_t> operator()(message& msg) const { maybe<size_t> operator()(message& msg) const {
return fun_ ? fun_(msg) : 0; return fun_ ? fun_(msg) : 0;
} }
std::function<optional<size_t> (message&)> fun_; std::function<maybe<size_t> (message&)> fun_;
}; };
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/config.hpp" #include "caf/config.hpp"
#include "caf/optional.hpp" #include "caf/maybe.hpp"
#include "caf/opencl/device.hpp" #include "caf/opencl/device.hpp"
#include "caf/opencl/global.hpp" #include "caf/opencl/global.hpp"
...@@ -53,11 +53,11 @@ public: ...@@ -53,11 +53,11 @@ public:
/// (Returns only devices of the first discovered platform). /// (Returns only devices of the first discovered platform).
const std::vector<device>& get_devices() const CAF_DEPRECATED; const std::vector<device>& get_devices() const CAF_DEPRECATED;
/// Get the device with id. These ids are assigned sequientally to all available devices. /// Get the device with id. These ids are assigned sequientally to all available devices.
const optional<const device&> get_device(size_t id = 0) const; const maybe<const device&> get_device(size_t id = 0) const;
/// Get the first device that satisfies the predicate. /// Get the first device that satisfies the predicate.
/// The predicate should accept a `const device&` and return a bool; /// The predicate should accept a `const device&` and return a bool;
template <class UnaryPredicate> template <class UnaryPredicate>
const optional<const device&> get_device_if(UnaryPredicate p) const { const maybe<const device&> get_device_if(UnaryPredicate p) const {
for (auto& pl : platforms_) { for (auto& pl : platforms_) {
for (auto& dev : pl.get_devices()) { for (auto& dev : pl.get_devices()) {
if (p(dev)) if (p(dev))
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include "caf/optional.hpp" #include "caf/maybe.hpp"
#include "caf/actor_cast.hpp" #include "caf/actor_cast.hpp"
#include "caf/detail/limited_vector.hpp" #include "caf/detail/limited_vector.hpp"
...@@ -43,7 +43,7 @@ struct tuple_construct { }; ...@@ -43,7 +43,7 @@ struct tuple_construct { };
template <class... Ts> template <class... Ts>
struct cl_spawn_helper { struct cl_spawn_helper {
using impl = opencl::actor_facade<Ts...>; using impl = opencl::actor_facade<Ts...>;
using map_in_fun = std::function<optional<message> (message&)>; using map_in_fun = std::function<maybe<message> (message&)>;
using map_out_fun = typename impl::output_mapping; using map_out_fun = typename impl::output_mapping;
actor operator()(const opencl::program& p, const char* fn, actor operator()(const opencl::program& p, const char* fn,
...@@ -177,7 +177,7 @@ template <class Fun, class... Ts> ...@@ -177,7 +177,7 @@ template <class Fun, class... Ts>
actor spawn_cl(const opencl::program& prog, actor spawn_cl(const opencl::program& prog,
const char* fname, const char* fname,
const opencl::spawn_config& config, const opencl::spawn_config& config,
std::function<optional<message> (message&)> map_args, std::function<maybe<message> (message&)> map_args,
Fun map_result, Fun map_result,
Ts... xs) { Ts... xs) {
detail::cl_spawn_helper<Ts...> f; detail::cl_spawn_helper<Ts...> f;
...@@ -194,7 +194,7 @@ template <class Fun, class... Ts> ...@@ -194,7 +194,7 @@ template <class Fun, class... Ts>
actor spawn_cl(const char* source, actor spawn_cl(const char* source,
const char* fname, const char* fname,
const opencl::spawn_config& config, const opencl::spawn_config& config,
std::function<optional<message> (message&)> map_args, std::function<maybe<message> (message&)> map_args,
Fun map_result, Fun map_result,
Ts... xs) { Ts... xs) {
detail::cl_spawn_helper<Ts...> f; detail::cl_spawn_helper<Ts...> f;
...@@ -227,7 +227,7 @@ actor spawn_cl(const char* source, ...@@ -227,7 +227,7 @@ actor spawn_cl(const char* source,
template <class Signature, class Fun> template <class Signature, class Fun>
actor spawn_cl(const opencl::program& prog, actor spawn_cl(const opencl::program& prog,
const char* fname, const char* fname,
std::function<optional<message> (message&)> map_args, std::function<maybe<message> (message&)> map_args,
Fun map_result, Fun map_result,
const opencl::dim_vec& dims, const opencl::dim_vec& dims,
const opencl::dim_vec& offset = {}, const opencl::dim_vec& offset = {},
...@@ -237,7 +237,7 @@ actor spawn_cl(const opencl::program& prog, ...@@ -237,7 +237,7 @@ actor spawn_cl(const opencl::program& prog,
template <class Signature, class Fun> template <class Signature, class Fun>
actor spawn_cl(const char* source, actor spawn_cl(const char* source,
const char* fname, const char* fname,
std::function<optional<message> (message&)> map_args, std::function<maybe<message> (message&)> map_args,
Fun map_result, Fun map_result,
const opencl::dim_vec& dims, const opencl::dim_vec& dims,
const opencl::dim_vec& offset = {}, const opencl::dim_vec& offset = {},
...@@ -286,7 +286,7 @@ actor spawn_cl(const char* source, ...@@ -286,7 +286,7 @@ actor spawn_cl(const char* source,
template <class Signature, class Fun> template <class Signature, class Fun>
actor spawn_cl(const opencl::program& prog, actor spawn_cl(const opencl::program& prog,
const char* fname, const char* fname,
std::function<optional<message> (message&)> map_args, std::function<maybe<message> (message&)> map_args,
Fun map_result, Fun map_result,
const opencl::dim_vec& dims, const opencl::dim_vec& dims,
const opencl::dim_vec& offset, const opencl::dim_vec& offset,
...@@ -305,7 +305,7 @@ actor spawn_cl(const opencl::program& prog, ...@@ -305,7 +305,7 @@ actor spawn_cl(const opencl::program& prog,
template <class Signature, class Fun> template <class Signature, class Fun>
actor spawn_cl(const char* source, actor spawn_cl(const char* source,
const char* fname, const char* fname,
std::function<optional<message> (message&)> map_args, std::function<maybe<message> (message&)> map_args,
Fun map_result, Fun map_result,
const opencl::dim_vec& dims, const opencl::dim_vec& dims,
const opencl::dim_vec& offset, const opencl::dim_vec& offset,
......
...@@ -145,7 +145,7 @@ void multiplier(event_based_actor* self) { ...@@ -145,7 +145,7 @@ void multiplier(event_based_actor* self) {
cout << "calculating square of matrix:" << endl cout << "calculating square of matrix:" << endl
<< to_string(m1) << endl; << to_string(m1) << endl;
auto unbox_args = [](message& msg) -> optional<message> { auto unbox_args = [](message& msg) -> maybe<message> {
return msg.apply( return msg.apply(
[](matrix_type& lhs, matrix_type& rhs) { [](matrix_type& lhs, matrix_type& rhs) {
return make_message(std::move(lhs.data()), std::move(rhs.data())); return make_message(std::move(lhs.data()), std::move(rhs.data()));
......
...@@ -37,7 +37,7 @@ const std::vector<device>& metainfo::get_devices() const { ...@@ -37,7 +37,7 @@ const std::vector<device>& metainfo::get_devices() const {
return platforms_.front().get_devices(); return platforms_.front().get_devices();
} }
const optional<const device&> metainfo::get_device(size_t id) const{ const maybe<const device&> metainfo::get_device(size_t id) const{
if (platforms_.empty()) if (platforms_.empty())
return none; return none;
size_t to = 0; size_t to = 0;
......
...@@ -252,7 +252,7 @@ void test_opencl() { ...@@ -252,7 +252,7 @@ void test_opencl() {
} }
); );
const matrix_type expected2(move(expected1)); const matrix_type expected2(move(expected1));
auto map_arg = [](message& msg) -> optional<message> { auto map_arg = [](message& msg) -> maybe<message> {
return msg.apply( return msg.apply(
[](matrix_type& mx) { [](matrix_type& mx) {
return make_message(move(mx.data())); return make_message(move(mx.data()));
......
...@@ -208,7 +208,7 @@ void test_opencl_deprecated() { ...@@ -208,7 +208,7 @@ void test_opencl_deprecated() {
} }
); );
const matrix_type expected2(std::move(expected1)); const matrix_type expected2(std::move(expected1));
auto map_arg = [](message& msg) -> optional<message> { auto map_arg = [](message& msg) -> maybe<message> {
return msg.apply( return msg.apply(
[](matrix_type& mx) { [](matrix_type& mx) {
return make_message(std::move(mx.data())); return make_message(std::move(mx.data()));
......
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