work on porting

This commit is contained in:
Matej Sekoranja
2014-05-19 22:33:40 +02:00
parent 4f63aba281
commit 2ef0abc67b
5 changed files with 394 additions and 241 deletions

View File

@@ -878,13 +878,13 @@ namespace pvAccess {
/**
* Interface for locating channel providers.
*/
class epicsShareClass ChannelAccess : private epics::pvData::NoDefaultMethods {
class epicsShareClass ChannelProviderRegistry : private epics::pvData::NoDefaultMethods {
public:
POINTER_DEFINITIONS(ChannelAccess);
POINTER_DEFINITIONS(ChannelProviderRegistry);
typedef std::vector<epics::pvData::String> stringVector_t;
virtual ~ChannelAccess() {};
virtual ~ChannelProviderRegistry() {};
/**
* Get a shared instance of the provider with the specified name.
@@ -907,7 +907,7 @@ namespace pvAccess {
virtual std::auto_ptr<stringVector_t> getProviderNames() = 0;
};
epicsShareExtern ChannelAccess::shared_pointer getChannelAccess();
epicsShareExtern ChannelProviderRegistry::shared_pointer getChannelProviderRegistry();
epicsShareExtern void registerChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory);
epicsShareExtern void unregisterChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory);

View File

@@ -20,7 +20,7 @@ using namespace epics::pvData;
namespace epics {
namespace pvAccess {
static ChannelAccess::shared_pointer channelAccess;
static ChannelProviderRegistry::shared_pointer ChannelProviderRegistry;
static Mutex channelProviderMutex;
@@ -28,7 +28,7 @@ typedef std::map<String, ChannelProviderFactory::shared_pointer> ChannelProvider
static ChannelProviderFactoryMap channelProviders;
class ChannelAccessImpl : public ChannelAccess {
class ChannelProviderRegistryImpl : public ChannelProviderRegistry {
public:
ChannelProvider::shared_pointer getProvider(String const & _providerName) {
@@ -68,14 +68,14 @@ class ChannelAccessImpl : public ChannelAccess {
}
};
ChannelAccess::shared_pointer getChannelAccess() {
ChannelProviderRegistry::shared_pointer getChannelProviderRegistry() {
static Mutex mutex;
Lock guard(mutex);
if(channelAccess.get()==0){
channelAccess.reset(new ChannelAccessImpl());
if(ChannelProviderRegistry.get()==0){
ChannelProviderRegistry.reset(new ChannelProviderRegistryImpl());
}
return channelAccess;
return ChannelProviderRegistry;
}
void registerChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory) {

File diff suppressed because it is too large Load Diff

View File

@@ -463,6 +463,37 @@ void RPCServer::run(int seconds)
m_serverContext->run(seconds);
}
struct ThreadRunnerParam {
RPCServer::shared_pointer server;
int timeToRun;
};
static void threadRunner(void* usr)
{
ThreadRunnerParam* pusr = static_cast<ThreadRunnerParam*>(usr);
ThreadRunnerParam param = *pusr;
delete pusr;
param.server->run(param.timeToRun);
}
/// Method requires usage of std::tr1::shared_ptr<RPCServer>. This instance must be
/// owned by a shared_ptr instance.
void RPCServer::runInNewThread(int seconds)
{
std::auto_ptr<ThreadRunnerParam> param(new ThreadRunnerParam());
param->server = rpcServer;
param->timeToRun = seconds;
epicsThreadCreate("RPCServer thread",
epicsThreadPriorityMedium,
epicsThreadGetStackSize(epicsThreadStackSmall),
threadRunner, param.get());
// let the thread delete 'param'
param.release();
}
void RPCServer::destroy()
{
m_serverContext->destroy();

View File

@@ -27,7 +27,9 @@
namespace epics { namespace pvAccess {
class epicsShareClass RPCServer {
class epicsShareClass RPCServer :
public std::tr1::enable_shared_from_this<RPCServer>
{
private:
ServerContextImpl::shared_pointer m_serverContext;
@@ -49,6 +51,10 @@ class epicsShareClass RPCServer {
void run(int seconds = 0);
/// Method requires usage of std::tr1::shared_ptr<RPCServer>. This instance must be
/// owned by a shared_ptr instance.
void runInNewThread(int seconds = 0);
void destroy();
/**