Re: [Cppcms-users] CppCMS 1.1 - Progress Report
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@gm...> - 2016-01-12 14:30:37
|
>
> In my big cppcms based application I have a custom session_storage and
> run into the problem
> that I need to access a shared resource (singleton class) of the
> process in the loaded so/dll.
> To solve this I made use of shared-memory to store the address of that
> shared object and access
> that information in my session_storage.
>
> Maybe there is a good way to extend the API to be able to pass a void
> pointer to shared_pool, extend the sessions_generator entry point and pass the custom void pointer to
> the entry_point.
>
>From what I can see your session storage is implemented in SO/DLL... and you
try to access a class in main process. Am I right?
I have two suggestions for you:
1. Don't load it from shared object/dll but rather use it directly via
installing it
via storage member function cppcms::session_pool (accessible via
cppcms::service)
This is possible the most obvious solution I can think of.
2. if you want to keep it as shared object you can open it
manually via booster::shared_object and get
your own signature you want and than install it into session_pool
your DLL/SO
extern "C" session_storage *my_generator(my_signeton &) { ... }
// main APP
booster::shared_object ob("libmystorage.so");
{
extern "C" session_storage (*gen)(my_signeton &)
ob.symbol(gen,"my_generator")
cppcms::service srv(argc,argv);
std::auto_ptr<session_storage> st(gen(my_singleton::instance());
srv.session_pool().storage(st);
}
3 Also in cppcms 1.1 you have new plugin API (not finalied yet) in
typesafe manner
So you can do stuff like this:
{
using cppcms::session::session_storage
using cppcms::plugin::manager;
cppcms::service srv(argc,argv);
{
booster::callback(session_storage *(my_signelton &)> gen
= manager().instance().entry<session_storage*(my_signelton
&)>("session","generator");
std::auto_ptr<session_storage> st(gen(my_singleton::instance());
srv.session_pool().storage(st);
}
...
}
while your function declared in SO/DLL as
namespace session {
session_storage *generator(my_signeton &) { ... }
CPPCMS_PLUGIN_ENTRY(session,generator,session_storage*(my_signelton
&));
}
> What is the deadline for the API freeze. I can come up with an RFC
> patch for discussion.
>
The API would be frozen at first RC think it would take at least a month.
> greets
> --
> Christian Gmeiner, MSc
>
> https://soundcloud.com/christian-gmeiner
>
Artyom Beilis
|