Exit gracefully if a port is bound by another process

This commit is contained in:
loki
2020-04-26 23:37:47 +02:00
parent 1a233ca4aa
commit e10c9a1fa1
5 changed files with 94 additions and 19 deletions

View File

@@ -311,13 +311,15 @@ public:
[[nodiscard]] ptr_t ref() {
std::lock_guard lg { _lock };
if(!_count++) {
if(!_count) {
new(_object_buf.data()) element_type;
if(_construct(*reinterpret_cast<element_type*>(_object_buf.data()))) {
return ptr_t { nullptr };
}
}
++_count;
return ptr_t { this };
}
private: