Commit Graph

12 Commits

Author SHA1 Message Date
Avi Kivity
f3c8994535 distributed: add map_reduce() variant accepting an initial value
Separating the initial value (and accumulator) from the reducer function
can result in simpler invocations.

Unfortunately, the name conflicts with another variant, so we have to name
the method map_reduce0.
2015-05-12 16:57:50 +03:00
Avi Kivity
7cf25ce492 distributed: fix use-after-move
distributed::stop() passes the pointer to the instance being destroyed
by reference, in an attempt to keep things clean (by nulling the pointer
after deleting it).  This is illegal, however, since the lambda is moved
in the bowels of submit_to().  In release mode this is optimized away so
the code works, but in debug mode it leads to a crash.

Fix by capturing by value instead (could also have been fixed by switching
the enclosing capture to a reference).

Credit to Gleb for identifying the problem.
2015-03-30 11:18:16 +03:00
Tomasz Grabiec
8abd982ec9 distributed: Do not move arguments when passing to many cores 2015-03-25 09:39:34 +01:00
Tomasz Grabiec
7bc7951192 core: Use perfect forwarding in invoke_on()/submit_to()
Makes invoking non-copyable lambdas possible:

  distributed<T> t;

  non_copyable_type x;
  t.invoke_on(0, [x = std::move(x)] (auto& t) {});

As a side effect this could save some copyable lambdas from being
needlesly copied.
2015-03-13 19:20:13 +02:00
Tomasz Grabiec
976c9da314 core: Add distributed::map_reduce() version which takes a functor 2015-03-11 13:33:01 +01:00
Tomasz Grabiec
56f6d12bae core: Fix map_reduce() which incorrectly moves away arguments 2015-03-11 13:21:23 +01:00
Avi Kivity
c35b61bda5 distributed: fix return type of lambda-friendly invoke_on()
result_of<> is mean to be used only with its 'type' member; use result_of_t
instead.
2015-02-22 16:20:36 +02:00
Avi Kivity
7f8d88371a Add LICENSE, NOTICE, and copyright headers to all source files.
The two files imported from the OSv project retain their original licenses.
2015-02-19 16:52:34 +02:00
Avi Kivity
b4098dac2f core: add distributed::invoke_on() variants not requiring a pointer to member
Current variants of distributed<T>::invoke_on() require member function to
invoke, which may be tedious to implement for some cases.  Add a variant
that supports invoking a functor, accepting the local instance by reference.
2015-02-18 16:52:56 +02:00
Takuya ASADA
be5568ae31 distributed: handle invoke_on with void return value
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-01-28 13:48:18 +02:00
Gleb Natapov
7a92efe8d1 core: add local engine accessor function
Do not use thread local engine variable directly, but use accessor
instead.
2015-01-27 14:46:49 +02:00
Takuya ASADA
e1552ad3b6 core: rename smp.hh to distributed.hh
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-01-14 11:16:09 +02:00