Project

General

Profile

Actions

Bug #3941

closed

GenericLinkService is impossible to inherit from

Added by Junxiao Shi about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Faces
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
0.50 h

Description

GenericLinkService has virtual inheritance from GenericLinkServiceCounters.
GenericLinkServiceCounters constructor takes GenericLinkService::m_reassembler as argument.

When a subclass inherits from GenericLinkService, the most derived class's constructor must directly invoke GenericLinkServiceCounters constructor.
However, it cannot do so because GenericLinkService::m_reassembler is private.

Actions #1

Updated by Junxiao Shi about 7 years ago

https://gerrit.named-data.net/3649 introduces a temporary workaround that GenericLinkServiceCounters inheritance is no longer virtual.
This improves the situation so that GenericLinkService can be inherited from, but the subclass would not be able to use a different Counters type.
This workaround should be reverted when this issue is resolved.

Actions #2

Updated by Junxiao Shi about 7 years ago

  • Assignee set to Eric Newberry
  • Estimated time set to 0.50 h

This issue is assigned to Eric who authored the GenericLinkServiceCounters constructor in nfd:commit:4c3e6b89a17c34d642d04fd5b37df447a939b9a6.

Actions #3

Updated by Eric Newberry about 7 years ago

I will start work on this issue after #3931 is merged, as it also modifies GenericLinkService.

Actions #4

Updated by Eric Newberry about 7 years ago

  • Status changed from New to In Progress
Actions #5

Updated by Eric Newberry about 7 years ago

  • Status changed from In Progress to Code review
  • % Done changed from 0 to 100
Actions #6

Updated by Junxiao Shi about 7 years ago

https://gerrit.named-data.net/3817 makes GenericLinkService::m_reassembler protected, so that GenericLinkService can be inherited from. However, this still requires every subclass to be aware of this and to call GenericLinkServiceCounters constructor directly. Moreover, if the same pattern is used, every new parameter of GenericLinkServiceCounters constructor would trigger a widespread change.
Is it possible to avoid this constructor parameter, so that subclass doesn't need to do anything?

I'm thinking about:

  • LpReassembler provides its counters in LpReassemblerCounters class.
  • GenericLinkServiceCounters inherits from LpReassemblerCounters.
  • LpReassembler constructor takes LpReassemblerCounters& parameter.
Actions #7

Updated by Davide Pesavento about 7 years ago

Junxiao Shi wrote:

https://gerrit.named-data.net/3817 makes GenericLinkService::m_reassembler protected, so that GenericLinkService can be inherited from. However, this still requires every subclass to be aware of this and to call GenericLinkServiceCounters constructor directly. Moreover, if the same pattern is used, every new parameter of GenericLinkServiceCounters constructor would trigger a widespread change.

I also dislike that solution.

  • LpReassembler provides its counters in LpReassemblerCounters class.
  • GenericLinkServiceCounters inherits from LpReassemblerCounters.
  • LpReassembler constructor takes LpReassemblerCounters& parameter.

I don't see how that would help... LpReassemblerCounters constructor would still require a const LpReassembler& parameter, no?

Actions #8

Updated by Davide Pesavento about 7 years ago

  • Start date deleted (02/01/2017)

In any case, I would suggest not spending any more time on this issue, at least until we have a better way to export those additional counters. Right now only the "basic" counters are made available to management clients, the rest are practically dead code. And adding support for additional counters is a very tedious process and doesn't scale that well, as it involves adding a new TLV type and changes to both the library and NFD's FaceManager, for each new type of counter.

Actions #9

Updated by Junxiao Shi about 7 years ago

I don't see how that would help... LpReassemblerCounters constructor would still require a const LpReassembler& parameter, no?

No.

LpReassembler constructor takes LpReassemblerCounters& parameter.

The counter variable is in LpReassemblerCounters, and LpReassembler stores a reference to LpReassemblerCounters. SizeCounter cannot be used, but LpReassembler has to manually increment and decrement the counter like ++m_counters.nReassembling when appropriate.

Actions #10

Updated by Davide Pesavento about 7 years ago

Junxiao Shi wrote:

The counter variable is in LpReassemblerCounters, and LpReassembler stores a reference to LpReassemblerCounters. SizeCounter cannot be used, but LpReassembler has to manually increment and decrement the counter like ++m_counters.nReassembling when appropriate.

Well, this changes everything. In particular, the critical change is to stop using SizeCounter, that's what solves the constructor issue, not the changes in note-7.

I don't like this solution either though, it feels more like a workaround than a proper solution.

How about:

  • SizeCounter is changed to observe a const T* instead of a const T&
  • SizeCounter removes its constructor parameter, or defaults it to nullptr, so that it can be default constructed, and in addition it gains a setObservedObject(const T*) member function
  • Either GenericLinkService or LpReassembler constructor calls setObservedObject on the nReassembling counter
Actions #11

Updated by Junxiao Shi about 7 years ago

I agree with note-10 design.

Actions #12

Updated by Junxiao Shi almost 7 years ago

  • Status changed from Code review to Closed
Actions

Also available in: Atom PDF