iceoryx icon indicating copy to clipboard operation
iceoryx copied to clipboard

Create singleton abstraction to avoid static destruction order problems

Open MatthiasKillat opened this issue 1 year ago • 1 comments

Brief feature description

The standard singleton implementation (static variable in function scope) does not allow multiple constructors and causes problems with destruction order if static variables depend on each other.

To avoid static destruction order problems a more general singleton abstraction can be created.

Detailed information

  • singleton abstraction shall allow destruction on demand
  • singleton abstraction shall allow arbitrary multi argument ctors

TBD

MatthiasKillat avatar Sep 22 '22 11:09 MatthiasKillat

This issue is not urgent and I will just move the ongoing PR https://github.com/eclipse-iceoryx/iceoryx/pull/1648 to this issue (requires changing commits and branch names etc.) This means the PR will be closed and reopened later after some updates.

@elBoberido We can also think about the singleton dependency graph here.

This is low prio and will be worked on when there is some time.

MatthiasKillat avatar Sep 22 '22 11:09 MatthiasKillat

Solved with the StaticLifetimeGuard in #1656 which basically manages a singleton that can be constructed lazily and whose lifetime can be controlled by guards. This class should satisfy all constraints stated here. so far

I therefore think this issue can be closed. We can consider optimizations and generalizations later.

Do you agree? @elBoberido

MatthiasKillat avatar Jan 31 '23 15:01 MatthiasKillat

@MatthiasKillat yes, this should be solved by the StaticLifetimeGuard

elBoberido avatar Jan 31 '23 15:01 elBoberido