celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [celix] Oipo commented on a change in pull request #293: Feature/add build to svc dep creation
Date Wed, 18 Nov 2020 19:14:18 GMT

Oipo commented on a change in pull request #293:
URL: https://github.com/apache/celix/pull/293#discussion_r526353213



##########
File path: libs/framework/include/celix/dm/Component_Impl.h
##########
@@ -63,7 +88,7 @@ Component<T>& Component<T>::addInterfaceWithName(const std::string
&serviceName,
 
 template<class T>
 template<class I>
-Component<T>& Component<T>::addInterface(const std::string &version,
const Properties &properties) {
+inline Component<T>& Component<T>::addInterface(const std::string &version,
const Properties &properties) {

Review comment:
       :laughing: 
   
   You've managed to use inline in both the situation where it is useless and exactly the
one type of situation where it is potentially necessary.
   
   Useless because templated functions are inline by default:
   ```c++
   template<typename T>
   inline void DependencyManager::destroyComponent(Component<T> &component) {
       celix_dependencyManager_remove(cDepMan, component.cComponent());
   }
   ```
   
   Totally necessary (if you want to keep it in a header file) because otherwise the function
gets defined multiple times:
   ```c++
   inline void DependencyManager::clear() {
       celix_dependencyManager_removeAllComponents(cDepMan.get());
       components.clear();
   }
   ```
   
   So one could make an argument that the `start()`, `build()`, `clear()`, `stop()`, `getNrOfComponents()`
etc functions should be put in a .cpp file with only their definitions in the header file,
since that would reduce compilation times and also solve the linking problem. This would create
a 'function' in assembly that would be called as you would expect.
   
   But inline there causes the function to not exist as a function but rather the assembly
of a function to get duplicated everywhere it would normally be called. Whether that actually
speeds things up is debatable, but it also means that there are no duplicate functions when
linking.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message