Skip to content

Conversation

vasild
Copy link
Contributor

@vasild vasild commented Dec 6, 2019

A few changes that remove the usage of boost from some places in the code.

Split GetAnnotation() to 3 functions that emit the result via an
output parameter and return true/false to designate whether it was
set or not.
@vasild
Copy link
Contributor Author

vasild commented Dec 11, 2019

The remaining boost usages would need bigger changes. Is fully removing boost to be attempted? The README contains "The boost dependency should be eliminated".

Copy link
Collaborator

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I'd like to merge this if the m_task_set double-destroy problem mentioned below is addressed.

The remaining boost usages would need bigger changes. Is fully removing boost to be attempted? The README contains "The boost dependency should be eliminated".

Yes, I'd like to remove the boost dependency, and I see after this PR the remaining boost::optional usages are more complicated to get rid of. One way might be to implement a small custom Optional template class that only supports needed emplace, reset, operator bool, and operator* methods. I don't think this would be too difficult to do. One way might be to start from another optional implementation like https://github.com/abseil/abseil-cpp/blob/master/absl/types/optional.h and just remove all the code there that isn't needed.

@vasild vasild force-pushed the reduce-boost-usage branch from e791cc5 to 8349490 Compare January 1, 2020 19:24
Copy link
Collaborator

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 8349490. Thanks for the change and followup!

@ryanofsky
Copy link
Collaborator

I'm seeing a compiler error due to a (pre-existing) missing include exposed by this change:

[ 85%] Building CXX object CMakeFiles/mpgen.dir/src/mp/gen.cpp.o
libmultiprocess/src/mp/gen.cpp: In function ‘void Generate(kj::StringPtr, kj::StringPtr, kj::StringPtr, kj::ArrayPtr<const kj::StringPtr>)’:
libmultiprocess/src/mp/gen.cpp:148:77: warning: ‘capnp::ParsedSchema capnp::SchemaParser::parseDiskFile(kj::StringPtr, kj::StringPtr, kj::ArrayPtr<const kj::StringPtr>) const’ is deprecated [-Wdeprecated-declarations]
     auto file_schema = parser.parseDiskFile(src_file, src_file, import_paths);
                                                                             ^
In file included from libmultiprocess/src/mp/gen.cpp:8:0:
include/capnp/schema-parser.h:103:16: note: declared here
   ParsedSchema parseDiskFile(kj::StringPtr displayName, kj::StringPtr diskPath,
                ^~~~~~~~~~~~~
libmultiprocess/src/mp/gen.cpp:169:10: error: ‘transform’ is not a member of ‘std’
     std::transform(guard.begin(), guard.end(), guard.begin(), [](unsigned char c) {
          ^~~~~~~~~

Adding #include <algorithm> to src/mp/gen.cpp fixes it. I'll try to edit the PR and merge it today if github will allow editing. If not, I'll just wait a day and merge this tomorrow, following up with the fix separately if still needed.

vasild added 2 commits January 6, 2020 16:01
Fall back to the KISS boolean flag denoting whether the variable is set
or not.
EventLoop::m_task_set was unnecessary defined as
boost::optional<kj::TaskSet> because it is always initialized.

It can, however, possibly be destroyed twice: in the EventLoop::loop()
method (conditional) and in the EventLoop destructor when it goes out of
scope (unconditional). So, use std::unique_ptr to handle this.
ryanofsky added a commit that referenced this pull request Jan 6, 2020
fb73b81 Change EventLoop::m_task_set to not use boost (Vasil Dimov)
138ad67 Change Field::(param and result) to not use boost (Vasil Dimov)
5724a2c Remove boost usage from GetAnnotation() (Vasil Dimov)
cab9c51 Remove unnecessary boost include (Vasil Dimov)

Pull request description:

  A few changes that remove the usage of boost from some places in the code.

Top commit has no ACKs.

Tree-SHA512: 5dc9698affd5b226ed227fe8ca3ce69bb2d21b46df7e760cbd8f82d026cad51ebf9787c9a40ad61244995eff1e25c81d523a051b75c4bad057c192736c449a9a
@ryanofsky ryanofsky merged commit fb73b81 into bitcoin-core:master Jan 6, 2020
@ryanofsky
Copy link
Collaborator

I was able to add the <algorithm> include and merge as abb3ae9. Thanks again!

@vasild
Copy link
Contributor Author

vasild commented Jan 6, 2020

Thanks! I was just about to fix it, but you were quicker :) I did not get that compilation error (clang 8.0.1), but I guess that is not so interesting now.

Next thing, time permitting, I will look to nuke the other boost usages.

@vasild vasild deleted the reduce-boost-usage branch January 6, 2020 21:09
@bitcoin-core bitcoin-core locked and limited conversation to collaborators Jun 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants