thread safety - Wrapper design in C++ -
i doing c++ work designing simulator utilize in test framework. anyways, scheme under test exposing rcf api using extensivly. problem allowed (to simulate real system) have single "rcf client" per connection. means have create utilize of clients thread safe.
normally phone call rcf method name:
client->methoda(param);
now instead have (i think) wrap each , every method in method containing mutex call:
virtual class rcfclientwrapper { protected: boost::mutex mtx; public: virtual rcfclientwrapper(); } class functionaclient:rcfclientwrapper { private: boost::shared_ptr<rcfclient<ircffunctiona_idl> > client; public: /*....stuff....*/ void methoda(param) { boost::lock_guard<boost::mutex> lock(mtx); client->methoda(param); } }
first of there improve way of doing this? second, there way of these little methods "automatically"? instead of having each every method? seems alot of unnecessary copy/pasta.
why don't consider using proxy class used implement proxy pattern in object interface or mediator other object.
c++ thread-safety rcf
No comments:
Post a Comment