Listening channels implemented
This commit is contained in:
@@ -37,21 +37,25 @@ Channel *DrivenEngine::get_chid(int chid) {
|
||||
return channels_[chid];
|
||||
}
|
||||
|
||||
void DrivenEngine::listen_port(int port) {
|
||||
listen_ports_.insert(port);
|
||||
}
|
||||
|
||||
double DrivenEngine::get_clock() {
|
||||
return clock_;
|
||||
}
|
||||
|
||||
std::unique_ptr<Channel> DrivenEngine::new_outgoing_channel(const std::string &target) {
|
||||
UniqueChannel DrivenEngine::new_outgoing_channel(const std::string &target) {
|
||||
int chid = find_unused_chid();
|
||||
new_outgoing_.insert(chid);
|
||||
return std::unique_ptr<Channel>(new Channel(this, chid, 0, target));
|
||||
return UniqueChannel(new Channel(this, chid, 0, target));
|
||||
}
|
||||
|
||||
std::unique_ptr<Channel> DrivenEngine::new_incoming_channel() {
|
||||
UniqueChannel DrivenEngine::new_incoming_channel() {
|
||||
if (accepted_channels_.empty()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
std::unique_ptr<Channel> result = std::move(accepted_channels_.back());
|
||||
UniqueChannel result = std::move(accepted_channels_.back());
|
||||
accepted_channels_.pop_back();
|
||||
return std::move(result);
|
||||
}
|
||||
@@ -73,6 +77,10 @@ void DrivenEngine::stop_driver() {
|
||||
stop_driver_ = true;
|
||||
}
|
||||
|
||||
void DrivenEngine::drv_get_listen_ports(std::set<int> &ports) {
|
||||
ports = listen_ports_;
|
||||
}
|
||||
|
||||
void DrivenEngine::drv_get_new_closed(std::set<int> &channels) {
|
||||
channels = std::move(new_closed_);
|
||||
new_closed_.clear();
|
||||
|
||||
Reference in New Issue
Block a user