Commit 66e1e756 authored by Kirill Smelkov's avatar Kirill Smelkov

libgolang: Provide select(vector<_selcase>)

We already provide select for array and std::initializer_list. However
when cases are constructed at runtime dynamically both array and
initializer_list are not convenient to use.

-> Provide select() overload that accepts vector<_selcase>.

This functionality will soon be used in C version of context package.
parent 85df1e40
......@@ -295,6 +295,7 @@ LIBGOLANG_API extern void (*_tblockforever)(void);
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
namespace golang {
......@@ -442,6 +443,11 @@ int select(const _selcase (&casev)[N]) {
return _chanselect(&casev[0], N);
}
static inline // select(vector<casev>)
int select(const std::vector<_selcase> &casev) {
return _chanselect(&casev[0], casev.size());
}
// defer(f) mimics `defer f()` from golang.
// NOTE contrary to Go f is called at end of current scope, not function.
#define defer(f) golang::_deferred _defer_ ## __COUNTER__ (f)
......
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