Recommendation for C++ wrapper for cross platform in-process dynamic library bindings (i.e. a lightweight, high performance COM or CORBA) [closed]
Asked Answered
P

2

9

We're developing an application that will have a plug-in "architecture" to allow consumers of the app to provide their own proprietary algorithms. (We will basically have a set of parsers and allow third parties to provide their own as well)

The domain space requires very high performance, so out-of-process bindings are not going to work and we'd rather leave the heavyweight things like CORBA and COM alone.

Basically we're looking for a simple cross-platform wrapper around:

  • load library from a relative path
  • provide a mapping of the particular dll/.so to some configuration/name
  • do some initialization and query the library to ensure it provides the necessary functionality

I think this is really just a wrapping around loadlibrary() and the method calls exported. We can write this ourselves, but we'd rather use existing code as we have enough on our plate.

Again, throughput and performance are very very important.

Similar questions are:

Cross-platform alternative to COM - this one is close, but we want in-process only - no need for out of process and our needs are a little "lighter weight".

C++ Cross Platform Dynamic Libraries; Linux and Windows

This is for unmanaged C++ - we cannot use .NET

EDIT - what we found

We found that Poco works great for our needs. As a bonus This page is a much appreciated comment on the state of C++ development and the language direction...

It was a simple cross platform wrapping that we needed that Poco provides. Really there is not much to it, but still saves us time and testing. No additional overhead during run time.

Pluralism answered 6/12, 2009 at 4:10 Comment(3)
I don't think anyone has bothered to do this explicitly for in-process. XPCOM is the best thing that comes to mind.Giff
@Tim: My comment is rather related to the idea of a plug-in "architecture" to allow consumers of the app to provide their own proprietary algorithms. So my project aims the same functionality but we have a serious problem that if user code goes through an infinite loop, the thread, on which the used code runs, locks one core of the CPU thus reduces the performance. Some how this thread must be stopped. So do you have the same problem? If yes, what is your solution?Banister
sad_man - you should create a new question for that. We have not solved that issue - nor is it on our to-do list yet.Pluralism
P
3

I think this might also work: http://pocoproject.org/docs/Poco.SharedLibrary.html

Pluralism answered 8/12, 2009 at 16:45 Comment(0)
P
4

The ACE library contains wrappers for dynamic library loading that work cross platform. If you want more comfort than plain loadlibrary then look at TAO The ACE ORB. Using corba with TAO is extremly performant and most likely beats any self crafted plugin infrastructure especially if you use in process calls, as TAO optimizes them.

To use the dynamic library cross platform wrapper use ACE_DLL. It provides the most basic cross platform wrapper around loadlibrary() that you mentioned.

In between using ACE_DLL and using TAO is the service configuration framework of ACE that allows you to dynamically load objects. After loading you can get an upcast pointer to the loaded object that you implemented and can call any method on the loaded object.

The code to do that would look like this:

char const * const cpc_myClass = ACE_DYNAMIC_SERVICE_DIRECTIVE(
  "myclass",
  "dllname",
  "_make_MyClass",
  ""
);
result = ACE_Service_Config::process_directive(cpc_myClass);
MyClass * p_obj = ACE_Dynamic_Service<MyClass>::instance ("myclass");
p_obj->callAnyMethodYouLike();

Here is explained that TAO knows two types of colocation optimization (thru_poa and direct):

When using the direct strategy, method invocations on collocated objects become direct calls to servant without checking POA's status.

You might be amazed how effective TAO can be if used correctly. I suggest to create a simple proof of concept and do measurements.

Pandean answered 7/12, 2009 at 12:53 Comment(4)
I am familiar with ACE - I don't need the "heavyweight" cross process or cross machine bindings though. I can't imagine that ACE is anywhere near the performance of one virtual call. What is the overhead of an ACE call?Pluralism
If you use the ACE_DLL class there are no cross process calls at all. Maybe you're not familiar enough with ACE? Even with TAO you can generate a 'direct' mapping that basically does just a virtual call when the called object is in the same process.Pandean
+1 Yes, I had used ACE as a corba implementation - not ace_dll - thanks for the suggestionPluralism
aould you please,please,please provide us with full code sample (compiling code so to say... with includes=)?Albina
P
3

I think this might also work: http://pocoproject.org/docs/Poco.SharedLibrary.html

Pluralism answered 8/12, 2009 at 16:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.