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

Simpler func for SimpleObjectPool #109

Merged
merged 4 commits into from
Oct 3, 2018
Merged

Simpler func for SimpleObjectPool #109

merged 4 commits into from
Oct 3, 2018

Conversation

AnthonySteele
Copy link
Contributor

Summarise the changes this Pull Request makes.

Simpler func for SimpleObjectPool

For the SimpleObjectPool constructor:

  • The constructor func can be Func<T>, we don't use the other param at all
  • the constructor func is IMHO a more important param than an initial size, so should come first
  • initial size has a default of zero

Please include a reference to a GitHub issue if appropriate.

Simpler func for SimpleObjectPool

For the SimpleObjectPool constructor:
- The constructor func can be `Func<T>`, we don't use the other param at all
- the constructor func is IMHO a more important param than an initial size, so should come first
- initial size has a default of zero
@AnthonySteele AnthonySteele requested a review from a team as a code owner October 2, 2018 14:05
@AnthonySteele
Copy link
Contributor Author

Timer test CorrectDurationForStatInAsyncFunction is failing in travis, but it Works On My Machine.

@AnthonySteele
Copy link
Contributor Author

AnthonySteele commented Oct 2, 2018

todo in a later PR: SimpleObjectPool<T> is only ever used as a SimpleObjectPool<Socket> - is the generic necessary?

ConnectedSocketPool is a wrapper of SimpleObjectPool<Socket>, which means that it's more complex, each operation is forwarded, incurring a tiny extra delay. Fold these classes together?

@@ -8,16 +8,16 @@ namespace JustEat.StatsD
/// </summary>
public sealed class SimpleObjectPool<T> where T : class
Copy link
Member

Choose a reason for hiding this comment

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

We can make this internal now too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, done

@martincostello
Copy link
Member

And yes you're right, the generic is also redundant now too.

@AnthonySteele
Copy link
Contributor Author

AnthonySteele commented Oct 3, 2018

I plan to make a later PR to fold SimpleObjectPool into ConnectedSocketPool as this is the only place where it is used. It will be simpler, and might remove some small run-time overhead - the indirection might or might not be optimised out.

I don't think that there are better options than this; as far as I know, there is no suitable generic pool class in the framework, and we are already doing something very close to this example

@AnthonySteele AnthonySteele merged commit 6773abe into master Oct 3, 2018
@martincostello martincostello deleted the simpler-func branch October 3, 2018 09:52
@martincostello martincostello added this to the v4.0.0 milestone Oct 5, 2018
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