-
Notifications
You must be signed in to change notification settings - Fork 297
Conversation
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # irohad/ametsuchi/impl/temporary_wsv_impl.cpp
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # irohad/ametsuchi/impl/temporary_wsv_impl.cpp
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # irohad/ametsuchi/impl/temporary_wsv_impl.cpp
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # irohad/ametsuchi/impl/temporary_wsv_impl.cpp
…/noncopyable_block
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # irohad/ametsuchi/impl/temporary_wsv_impl.cpp
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # irohad/ametsuchi/impl/temporary_wsv_impl.cpp
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # test/benchmark/CMakeLists.txt # test/benchmark/bm_proto_creation.cpp
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # test/benchmark/CMakeLists.txt # test/benchmark/bm_proto_creation.cpp
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # test/benchmark/CMakeLists.txt # test/benchmark/bm_proto_creation.cpp
b10ed3a
to
55deaad
Compare
This prevents initialization bug from old versions of gcc (pre 7.2) Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # test/benchmark/CMakeLists.txt # test/benchmark/bm_proto_creation.cpp
55deaad
to
e389a49
Compare
It enforces no-copy for all derived classes Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # test/benchmark/CMakeLists.txt # test/benchmark/bm_proto_creation.cpp
CMakeLists.txt
Outdated
@@ -110,6 +110,8 @@ include_directories( | |||
|
|||
SET(IROHA_ROOT_PROJECT ON) | |||
|
|||
add_definitions(-DBOOST_NO_RTTI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls, add a comment with the purpose of usage of the flag.
return rxcpp::observable<>::create<PostgresBlockQuery::wBlock>( | ||
[block{std::move(block)}](const auto &s) { | ||
if (block) { | ||
[i, this](const auto &s) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe rename i
and s
with some more meaningful names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i is just a counter so i think its fine. s will be renamed
@@ -1,4 +1,5 @@ | |||
add_library(shared_model_proto_backend | |||
block.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, block.cpp
should be moved to impl/
folder regards to the rest files in the target.
public: | ||
using TransportType = Proto; | ||
|
||
template <typename Transport> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add use case of ctor. The documentation should contain information about copy/move semantic of ctor.
@@ -63,7 +66,7 @@ namespace shared_model { | |||
if (boost::size(object_.signatures()) == 0) { | |||
throw std::invalid_argument("Cannot get object without signatures"); | |||
} | |||
return object_; | |||
return std::move(object_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about the safety of this method because its class may be in bindings. So, here we have to care about signAndAddSignature
method and check that this method works correctly.
test/benchmark/bm_proto_creation.cpp
Outdated
st.SetIterationTime(elapsed_seconds.count()); | ||
} | ||
|
||
BENCHMARK_DEFINE_F(BlockBenchmark, TransportCopyTest)(benchmark::State &st) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add documentation about a semantic of the performance test. Also, this issue is related to tests below.
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # test/benchmark/CMakeLists.txt # test/benchmark/bm_proto_creation.cpp
742cc30
to
f0072b0
Compare
* NOTE: finish() moves internal object, so it is unsafe to call it more | ||
* than once on the single instance. | ||
* NOTE: finish() moves internal object, so calling methods after | ||
* finish() throws an exception | ||
*/ | ||
template <typename T> | ||
class UnsignedWrapper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls, add move ctor for the class.
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # test/benchmark/CMakeLists.txt # test/benchmark/bm_proto_creation.cpp
block.value())); | ||
} | ||
s.on_completed(); | ||
[i, this](const auto &block_observer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So block_observer
-> subscriber
as it seems to me.
[](auto &&x) { return wBlock(clone(x)); }))); | ||
auto block = loader->retrieveBlock(peer_key, kPrevHash); | ||
.WillOnce(Return(rxcpp::observable<>::just(wBlock(clone(present))))); | ||
auto block = loader->retrieveBlock(peer_key, Hash(std::string(32, '0'))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
32
looks like magic, so maybe use kPrevHash
?
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com> # Conflicts: # test/benchmark/CMakeLists.txt # test/benchmark/bm_proto_creation.cpp
SonarQube analysis reported 1 issue
|
Implement non-copyable block Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com>
Implement non-copyable block Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com>
Implement non-copyable block Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com>
Implement non-copyable block Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com>
Implement non-copyable block Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com>
Description of the Change
This Pull Request refactors proto block to be non-copy constructible. Adds move semantics for the block.
Benefits
Block no longer can be copied. Additionally, moving a block is faster
Possible Drawbacks
Cannot copy blocks