#1 2014-10-03 18:04:19

Langley
Member
Registered: 2014-08-29
Posts: 4

Confusion over the behavior of the example code

I know I'm missing something, so I'll just say that at the outset.

The example code in the 2.1.0 branch has a great little driver that is wonderful for exploring the behavior of the framework. However, it exhibits a behavior that I'm having a hard time replicating on my own.

When I use the example code, I can load the dictionaryclient service and somehow the dictionaryservice gets loaded. The problem is I don't know how. It's as though autoloading is working, but I'm reasonably certain that this isn't the case because when autoloading "kicks in" there are log messages printed to the console and in the case of the example driver, that doesn't happen. I know all the libmoduleXXX.so files are located in the same directory and I've included that in my "test scenario" where I'm trying to replicate the behavior.

Am I missing some special relationship between the dictionaryclient and the dictionaryservice?

Another way of expressing my confusion is to ask how the relationship between the dictionaryclient and dictionaryservice is different from a scenario where autoloading is needed.

Thanks in advance!

- Langley

Offline

#2 2014-10-03 18:26:43

sascha
Administrator
Registered: 2012-05-04
Posts: 46

Re: Confusion over the behavior of the example code

I am almost certain that you are experiencing the differences between link-time dependencies and logical dependencies between modules.

The dictionaryclient module uses the service interface contained in the dictionaryservice module which has an out-of-line virtual destructor. This leads to a link-time dependency on platforms with are "not smart enough" to remove this dependency during link-time optimizations. The note in Example 6 talks about this issue. I have to admit that this is a little detail worth knowing, because its effects are very important.

In the example, the dictionaryservice module provides the service interface (with an out-of-line destructor for consisted behaviour of dynamic casts across shared library boundaries) and an implementation of the service interface. If you decouple these two (by either providing an inline destructor or splitting it into two modules for the interface and the implementation), auto-loading comes in handy to load the implementation module.

I hope this helps,

Sascha

Offline

#3 2014-10-03 19:29:10

Langley
Member
Registered: 2014-08-29
Posts: 4

Re: Confusion over the behavior of the example code

You are absolutely right!

I used readelf to look at the dynamic section of libdictionaryclient.so and saw a reference to libdictionaryservice.so, so I made an explicit link in my example (using -l as I built it) to create the same relationship and voila, it recreated the behavior I saw in the example driver. Without the link during build time of course it requires autoloading or explicit library loading to get them both in memory.

Thank you!

- Langley

Offline

Board footer

Powered by FluxBB