Skip to content

Commit b1ee845

Browse files
author
Henry Hoegelow
committed
fix lowest computation wins algorithm
1 parent d58f19a commit b1ee845

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ add_library(reactive STATIC
2424
src/Var.cpp
2525
)
2626

27-
if(CMAKE_BUILD_TYPE MATCHES "Debug")
28-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
29-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
30-
endif()
27+
#if(CMAKE_BUILD_TYPE MATCHES "Debug")
28+
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
29+
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
30+
#endif()
3131

3232
target_include_directories(reactive PRIVATE ./src)
3333
target_include_directories(reactive PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)

include/reactive/Latch.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,20 @@ namespace Reactive
2424
self.execute();
2525
}
2626

27-
Computation *getLowest(Computation *lowestSoFar) const override
27+
Computation* getLowest(Computation* lowestSoFar) const override
2828
{
29-
return self.m_dirty? self.m_computation.get() : nullptr;
29+
if(!self.m_dirty)
30+
self.resolveDirtynessDownstream();
31+
32+
if(!self.m_dirty)
33+
return lowestSoFar;
34+
35+
auto my = self.m_computation.get();
36+
37+
if(!lowestSoFar)
38+
return my;
39+
40+
return my->getDepth() < lowestSoFar->getDepth() ? lowestSoFar : my;
3041
}
3142
};
3243

src/ComputationsImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ namespace Reactive
5757
lowestSoFar = it->get();
5858
return lowestSoFar;
5959
}
60-
} // namespace Reactive
60+
}

0 commit comments

Comments
 (0)