Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keeping up to date with Bricks and FNCAS + minor cleanup. #12

Merged
merged 13 commits into from
Mar 25, 2015
Merged

Keeping up to date with Bricks and FNCAS + minor cleanup. #12

merged 13 commits into from
Mar 25, 2015

Conversation

dkorolev
Copy link
Contributor

No description provided.

@dkorolev
Copy link
Contributor Author

Uses KnowSheet/fncas#5.

Thanks!
Dima

@dkorolev
Copy link
Contributor Author

And merged in #13.

@sompylasar : Could you please take a look? Max is busy for the next few days. Thanks!

@dkorolev dkorolev assigned sompylasar and unassigned mzhurovich Mar 24, 2015
};

struct HTTPRequestMQMessage : schema::Base {
Request request;
std::function<void(Request, Box&)> http_function_with_box;
std::function<void(Request, Snapshot&)> http_function_with_box;
Copy link
Contributor

Choose a reason for hiding this comment

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

_with_snapshot?

@sompylasar
Copy link
Contributor

@dkorolev LGTM. Minor nits.

@dkorolev
Copy link
Contributor Author

Fixed the minor things.

The const issue:

  1. The entry should be passed as non-const. This is to allowing moving unique_ptr-s out of the caller thread into message queues for other threads. If the design enforces the passed in objects to be mutable, it's easy (just std::move them away), while if the design does not, it's up to the user to clone those objects, which is a pain for polymorphics.
  2. A non-const entry can be passed on to a const-accepting method. So this part is solid.
  3. Nonetheless, map::operator[] is mutable in C++ (it will create non-existing entries with default values, in order to be able to return references), and to keep using array-style indexing I simply kept one of two Entry-accepting method take a mutable input.

@sompylasar : PTAL. Thanks!

sompylasar added a commit that referenced this pull request Mar 25, 2015
Keeping up to date with Bricks and FNCAS + minor cleanup.
@sompylasar sompylasar merged commit 414dd0c into KnowSheet:master Mar 25, 2015
@sompylasar
Copy link
Contributor

Thanks for the thorough explanation!

Which is preferred: having const or not in the Entry method signature? I
saw both around the code, and I've recently copy-pasted the non-const one
into the db/test.
25.03.2015 9:06 пользователь "Dima" [email protected] написал:

Fixed the minor things.

The const issue:

The entry should be passed as non-const. This is to allowing moving
unique_ptr-s out of the caller thread into message queues for other
threads. If the design enforces the passed in objects to be mutable, it's
easy (just std::move them away), while if the design does not, it's up
to the user to clone those objects, which is a pain for polymorphics.
2.

A non-const entry can be passed on to a const-accepting method. So
this part is solid.
3.

Nonetheless, map::operator[] is mutable in C++ (it will create
non-existing entries with default values, in order to be able to return
references), and to keep using array-style indexing I simply kept one of
two Entry-accepting method take a mutable input.

@sompylasar https://github.com/sompylasar : PTAL. Thanks!


Reply to this email directly or view it on GitHub
#12 (comment)
.

@dkorolev
Copy link
Contributor Author

I'd suggest we go with non-const and override (virtual bool Entry(SomeType& entry, size_t, size_t) override { ... }) whenever possible.

Even though currently the dispatching is done via template magic, not virtual functions table, and thus virtual and override are not necessary, I can totally see a lot of usecases for them in the future, and would prefer to be proactively ready for them.

@sompylasar
Copy link
Contributor

@dkorolev Maybe add this suggestion somewhere into the Sherlock docs?

@dkorolev
Copy link
Contributor Author

👍 KnowSheet/Sherlock#11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants