This is Unofficial EPICS BASE Doxygen Site
epics::pvAccess::ServerChannel Class Reference

#include "serverChannelImpl.h"

+ Collaboration diagram for epics::pvAccess::ServerChannel:

Public Member Functions

 POINTER_DEFINITIONS (ServerChannel)
 
 ServerChannel (Channel::shared_pointer const &channel, const ChannelRequester::shared_pointer &requester, pvAccessID cid, pvAccessID sid)
 
 ~ServerChannel ()
 
const Channel::shared_pointer & getChannel () const
 
pvAccessID getCID () const
 
pvAccessID getSID () const
 
void registerRequest (pvAccessID id, const std::tr1::shared_ptr< BaseChannelRequester > &request)
 
void unregisterRequest (pvAccessID id)
 
void installGetField (const GetFieldRequester::shared_pointer &gf)
 
void completeGetField (GetFieldRequester *req)
 
std::tr1::shared_ptr< BaseChannelRequestergetRequest (pvAccessID id)
 may return NULL More...
 
void destroy ()
 
void printInfo () const
 
void printInfo (FILE *fd) const
 

Static Public Attributes

static size_t num_instances
 

Detailed Description

Definition at line 20 of file serverChannelImpl.h.

Constructor & Destructor Documentation

epics::pvAccess::ServerChannel::ServerChannel ( Channel::shared_pointer const &  channel,
const ChannelRequester::shared_pointer &  requester,
pvAccessID  cid,
pvAccessID  sid 
)

Create server channel for given process variable.

Parameters
channellocal channel.
cidchannel CID.
sidchannel SID.
csschannel security session.

Definition at line 19 of file serverChannelImpl.cpp.

21  :
22  _channel(channel),
23  _requester(requester),
24  _cid(cid),
25  _sid(sid),
26  _destroyed(false)
27 {
28  REFTRACE_INCREMENT(num_instances);
29  if (!channel.get())
30  {
31  THROW_BASE_EXCEPTION("non-null channel required");
32  }
33 }
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
#define THROW_BASE_EXCEPTION(msg)
epics::pvAccess::ServerChannel::~ServerChannel ( )

Definition at line 93 of file serverChannelImpl.cpp.

94 {
95  destroy();
96  REFTRACE_DECREMENT(num_instances);
97 }

Member Function Documentation

void epics::pvAccess::ServerChannel::completeGetField ( GetFieldRequester req)

Definition at line 123 of file serverChannelImpl.cpp.

124 {
125  GetFieldRequester::shared_pointer prev;
126  {
127  epicsGuard<epicsMutex> G(_mutex);
128  if(_active_requester.get()==req)
129  prev.swap(_active_requester);
130  }
131 }
void epics::pvAccess::ServerChannel::destroy ( )

Definition at line 63 of file serverChannelImpl.cpp.

64 {
65  _requests_t reqs;
66  {
67  Lock guard(_mutex);
68 
69  if (_destroyed) return;
70  _destroyed = true;
71 
72  // destroy all requests
73  // take ownership of _requests locally to prevent
74  // removal via unregisterRequest() during iteration
75  _requests.swap(reqs);
76 
77  // ... and the channel
78  // TODO try catch
79  _channel->destroy();
80  }
81  // unlock our before destroy.
82  // our mutex is subordinate to operation mutex
83 
84  for(_requests_t::const_iterator it=reqs.begin(), end=reqs.end(); it!=end; ++it)
85  {
86  const _requests_t::mapped_type& req = it->second;
87  // will call unregisterRequest() which is now a no-op
88  req->destroy();
89  // May still be in the send queue
90  }
91 }
A lock for multithreading.
Definition: lock.h:36
const Channel::shared_pointer& epics::pvAccess::ServerChannel::getChannel ( ) const
inline

Definition at line 39 of file serverChannelImpl.h.

39 { return _channel; }
pvAccessID epics::pvAccess::ServerChannel::getCID ( ) const
inline

Definition at line 41 of file serverChannelImpl.h.

41 { return _cid; }
std::tr1::shared_ptr< BaseChannelRequester > epics::pvAccess::ServerChannel::getRequest ( pvAccessID  id)

may return NULL

Definition at line 52 of file serverChannelImpl.cpp.

53 {
54  Lock guard(_mutex);
55  _requests_t::iterator iter = _requests.find(id);
56  if(iter != _requests.end())
57  {
58  return iter->second;
59  }
60  return BaseChannelRequester::shared_pointer();
61 }
A lock for multithreading.
Definition: lock.h:36
pvAccessID epics::pvAccess::ServerChannel::getSID ( ) const
inline

Definition at line 43 of file serverChannelImpl.h.

43 { return _sid; }
void epics::pvAccess::ServerChannel::installGetField ( const GetFieldRequester::shared_pointer &  gf)

Definition at line 110 of file serverChannelImpl.cpp.

111 {
112  GetFieldRequester::shared_pointer prev;
113  {
114  epicsGuard<epicsMutex> G(_mutex);
115  prev.swap(_active_requester);
116  _active_requester = gf;
117  }
118  if(prev) {
119  prev->getDone(Status::error("Aborted"), FieldConstPtr());
120  }
121 }
static Status error(const std::string &m)
Definition: status.h:50
std::tr1::shared_ptr< const Field > FieldConstPtr
Definition: pvIntrospect.h:137
epics::pvAccess::ServerChannel::POINTER_DEFINITIONS ( ServerChannel  )
void epics::pvAccess::ServerChannel::printInfo ( ) const

Definition at line 99 of file serverChannelImpl.cpp.

100 {
101  printInfo(stdout);
102 }
#define stdout
Definition: epicsStdio.h:30
void epics::pvAccess::ServerChannel::printInfo ( FILE *  fd) const

Definition at line 104 of file serverChannelImpl.cpp.

105 {
106  fprintf(fd,"CLASS : %s\n", typeid(*this).name());
107  fprintf(fd,"CHANNEL : %s\n", typeid(*_channel).name());
108 }
void epics::pvAccess::ServerChannel::registerRequest ( pvAccessID  id,
const std::tr1::shared_ptr< BaseChannelRequester > &  request 
)

Definition at line 35 of file serverChannelImpl.cpp.

36 {
37  Lock guard(_mutex);
38  if(_destroyed) throw std::logic_error("Can't registerRequest() for destory'd server channel");
39  _requests[id] = request;
40 }
std::string request
A lock for multithreading.
Definition: lock.h:36
void epics::pvAccess::ServerChannel::unregisterRequest ( pvAccessID  id)

Definition at line 42 of file serverChannelImpl.cpp.

43 {
44  Lock guard(_mutex);
45  _requests_t::iterator iter = _requests.find(id);
46  if(iter != _requests.end())
47  {
48  _requests.erase(iter);
49  }
50 }
A lock for multithreading.
Definition: lock.h:36

Member Data Documentation

size_t epics::pvAccess::ServerChannel::num_instances
static

Definition at line 25 of file serverChannelImpl.h.


The documentation for this class was generated from the following files: