Skip to content

Commit 08e4171

Browse files
authored
Merge pull request #301 from jaafari/master
add unbind to enable runtime binding/unbinding
2 parents d1bb5b4 + 391df59 commit 08e4171

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

include/rpc/dispatcher.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ class dispatcher {
6060
detail::tags::nonvoid_result const &,
6161
detail::tags::nonzero_arg const &);
6262

63+
//! \brief Unbind a functor with a given name from callable functors.
64+
void unbind(std::string const &name) {
65+
funcs_.erase(name);
66+
}
67+
68+
//! \brief returns a list of all names which functors are binded to
69+
std::vector<std::string> names() const {
70+
std::vector<std::string> names;
71+
for(auto it = funcs_.begin(); it != funcs_.end(); ++it)
72+
names.push_back(it->first);
73+
return names;
74+
}
75+
6376
//! @}
6477

6578
//! \brief Processes a message that contains a call according to

include/rpc/server.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,24 @@ class server {
9393
disp_->bind(name, func);
9494
}
9595

96+
//! \brief Unbinds a functor binded to a name.
97+
//!
98+
//! This function removes already binded function from RPC Ccallable functions
99+
//!
100+
//! \param name The name of the functor.
101+
void unbind(std::string const &name) {
102+
disp_->unbind(name);
103+
}
104+
105+
//! \brief Returns all binded names
106+
//!
107+
//! This function returns a list of all names which functors are binded to
108+
//!
109+
//! \param name The name of the functor.
110+
std::vector<std::string> names() const {
111+
return disp_->names();
112+
}
113+
96114
//! \brief Sets the exception behavior in handlers. By default,
97115
//! handlers throwing will crash the server. If suppressing is on,
98116
//! the server will try to gather textual data and return it to

0 commit comments

Comments
 (0)