diff --git a/examples/concurrency.cc b/examples/concurrency.cc index 9730ecf..eccf49f 100644 --- a/examples/concurrency.cc +++ b/examples/concurrency.cc @@ -13,6 +13,10 @@ using namespace ostd; * task, which may or may not run in parallel with the other one depending * on the scheduler currently in use - several schedulers are shown */ +auto input_array = { 150, 38, 76, 25, 67, 18, -15, 215, 25, -10 }; + +auto first_half = iter(input_array).slice(0, input_array.size() / 2); +auto second_half = iter(input_array).slice(input_array.size() / 2); /* this version uses Go-style channels to exchange data; multiple * tasks can put data into channels, the channel itself is a thread @@ -20,14 +24,12 @@ using namespace ostd; * wait on a channel for some data to be received */ static void test_channel() { - auto arr = { 150, 38, 76, 25, 67, 18, -15, 215, 25, -10 }; - auto c = make_channel(); auto f = [](auto c, auto half) { c.put(foldl(half, 0)); }; - spawn(f, c, iter(arr).slice(0, arr.size() / 2)); - spawn(f, c, iter(arr).slice(arr.size() / 2)); + spawn(f, c, first_half); + spawn(f, c, second_half); int a = c.get(); int b = c.get(); @@ -48,13 +50,11 @@ static void test_channel() { * from t2; in the above test, a can come from either task */ static void test_tid() { - auto arr = { 150, 38, 76, 25, 67, 18, -15, 215, 25, -10 }; - auto f = [](auto half) { return foldl(half, 0); }; - auto t1 = spawn(f, iter(arr).slice(0, arr.size() / 2)); - auto t2 = spawn(f, iter(arr).slice(arr.size() / 2)); + auto t1 = spawn(f, first_half); + auto t2 = spawn(f, second_half); int a = t1.get(); int b = t2.get(); diff --git a/ostd/coroutine.hh b/ostd/coroutine.hh index 2f72c55..7a1462a 100644 --- a/ostd/coroutine.hh +++ b/ostd/coroutine.hh @@ -377,11 +377,6 @@ release: void (*p_free)(void *) = nullptr; }; -/** @brief Unspecialized declaration of the coroutine. - * - * This one has no definition. All instances of coroutine must use `R(A...)` - * as template arguments, which is specialized later. - */ template struct coroutine; diff --git a/ostd/stream.hh b/ostd/stream.hh index e509c89..12b5b03 100644 --- a/ostd/stream.hh +++ b/ostd/stream.hh @@ -80,11 +80,7 @@ enum class stream_seek { SET = SEEK_SET ///< Beginning of the stream. }; -/** @brief A stream range class without a definition. - * - * Stream ranges only work with POD types. This variant is instantiated - * for non-POD types and as it has no definition, it will fail to compile. - */ + template> struct stream_range; @@ -545,6 +541,9 @@ private: * therefore not be readable from the stream again (from another range for * example). * + * This template is a specialization of undefined base type because stream + * ranges only work with POD types. + * * @see stream_line_range */ template