-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #466 from JetBrains/ab-fix-callback-lifetimes
Pack of RD lifetimes fixes + auto-binding for task results
- Loading branch information
Showing
19 changed files
with
564 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef LIFETIME_UTIL_H | ||
#define LIFETIME_UTIL_H | ||
|
||
#include <memory> | ||
#include "../lifetime/LifetimeDefinition.h" | ||
|
||
namespace rd | ||
{ | ||
namespace util | ||
{ | ||
/// \brief Attaches lifetime to shared_ptr. Lifetime terminates when shared_ptr destructed. | ||
/// \param original original pointer which will be used to make a new pointer with lifetime. | ||
/// \param lifetime_definition Lifetime definition associated with returned shared_ptr. | ||
/// \return New shared_ptr which owns lifetime_definition and terminates that lifetime when destroyed. | ||
template <typename T> | ||
static std::shared_ptr<T> attach_lifetime(std::shared_ptr<T> original, LifetimeDefinition lifetime_definition) | ||
{ | ||
struct Deleter | ||
{ | ||
std::shared_ptr<T> ptr; | ||
LifetimeDefinition lifetime_definition; | ||
|
||
explicit Deleter(LifetimeDefinition&& lifetime_definition, std::shared_ptr<T> ptr) : ptr(std::move(ptr)), lifetime_definition(std::move(lifetime_definition)) { } | ||
|
||
void operator()(T*) const | ||
{ | ||
} | ||
}; | ||
|
||
auto raw_ptr = original.get(); | ||
auto deleter = Deleter(std::move(lifetime_definition), std::move(original)); | ||
return std::shared_ptr<T>(raw_ptr, std::move(deleter)); | ||
} | ||
} | ||
} | ||
|
||
#endif //LIFETIME_UTIL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.