mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-29 01:15:43 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b9afab26d |
@@ -994,8 +994,8 @@ auto CalcOne(
|
||||
&settingsGetter,
|
||||
&allCastleCoords,
|
||||
&apdCache,
|
||||
&alCache]() -> ScoreValue {
|
||||
auto lookaheadFuture = BasicLookaheadCalculator(
|
||||
&alCache]() -> std::future<ScoreValue> {
|
||||
return BasicLookaheadCalculator(
|
||||
pid,
|
||||
isDefender,
|
||||
remainingLookahead,
|
||||
@@ -1007,16 +1007,20 @@ auto CalcOne(
|
||||
allCastleCoords,
|
||||
apdCache,
|
||||
alCache);
|
||||
return lookaheadFuture.get();
|
||||
};
|
||||
|
||||
#if MULTITHREAD
|
||||
returnValue.lookaheadScore = std::async(std::launch::async, lookaheadLambda);
|
||||
// Use async to run the lambda in parallel, then chain the resulting future
|
||||
auto futureOfFuture = std::async(std::launch::async, lookaheadLambda);
|
||||
returnValue.lookaheadScore = std::async(
|
||||
std::launch::deferred,
|
||||
[futureOfFuture = std::move(futureOfFuture)]() mutable -> ScoreValue {
|
||||
auto innerFuture = futureOfFuture.get();
|
||||
return innerFuture.get();
|
||||
});
|
||||
#else
|
||||
std::promise<ScoreValue> p;
|
||||
returnValue.lookaheadScore = p.get_future();
|
||||
auto lambdaResult = lookaheadLambda();
|
||||
p.set_value(lambdaResult);
|
||||
// In single-threaded mode, just call the lambda directly
|
||||
returnValue.lookaheadScore = lookaheadLambda();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user