From 48804e8faae8334aae192b84e92baa5c62a1635d Mon Sep 17 00:00:00 2001 From: FritzFlorian Date: Thu, 11 Apr 2019 16:57:21 +0200 Subject: [PATCH] Add notes on why anonymous, generic lambda wrappers are not possible in our context. --- NOTES.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/NOTES.md b/NOTES.md index 5a07756..d8de36a 100644 --- a/NOTES.md +++ b/NOTES.md @@ -4,6 +4,29 @@ A collection of stuff that we noticed during development. Useful later on two write a project report and to go back in time to find out why certain decisions where made. +## 11.04.2019 - Lambda Pointer Abstraction + +The question is if we could use a pointer to a lambda without +needing templating (for the type of the lambda) at the place that +we use it. + +We looked into different techniques to achieve this: +- Using std::function<...> +- Using custom wrappers + +std::function uses dynamic memory, thus ruling it out. +All methods that we can think of involve storing a pointer +to the lambda and then calling on it later on. +This works well enough with a simple wrapper, but has one +major downside: It involves virtual function calls, +making it impossible to inline the lambda. +This property broke the technique for us in most places, +as inlining is crucial, especially in small functions like loop +iterations. See `invoke_parallel_impl.h` for an example where we +did this (wrapper with virtual function call), but we only did it there, +as the generic `fork_join_sub_task` requires the virtual call anyway, +thus making us not loose ANY performance with this technique. + ## 11.04.2019 - Notes on C++ Templating After working more with templating and talking to mike, -- libgit2 0.26.0