@@ -28,9 +28,15 @@ UnboundBuffer::UnboundBuffer(
2828 recvRank_(-1 ),
2929 sendCompletions_(0 ),
3030 sendRank_(-1 ),
31- shareableNonOwningPtr_(this ) {}
31+ shareableNonOwningPtr_(this ) {
32+ gloo::_register_cv (&recvCv_);
33+ gloo::_register_cv (&sendCv_);
34+ }
3235
33- UnboundBuffer::~UnboundBuffer () {}
36+ UnboundBuffer::~UnboundBuffer () {
37+ gloo::_deregister_cv (&recvCv_);
38+ gloo::_deregister_cv (&sendCv_);
39+ }
3440
3541void UnboundBuffer::handleRecvCompletion (int rank) {
3642 std::lock_guard<std::mutex> lock (mutex_);
@@ -58,8 +64,12 @@ bool UnboundBuffer::waitRecv(int* rank, std::chrono::milliseconds timeout) {
5864 }
5965
6066 if (recvCompletions_ == 0 ) {
61- auto done = recvCv_.wait_for (
62- lock, timeout, [&] { return abortWaitRecv_ || recvCompletions_ > 0 ; });
67+ auto done = recvCv_.wait_for (lock, timeout, [&] {
68+ if (gloo::_is_aborted ()) {
69+ abortWaitRecv_ = true ;
70+ }
71+ return abortWaitRecv_ || recvCompletions_ > 0 ;
72+ });
6373 if (!done) {
6474 throw ::gloo::IoException (GLOO_ERROR_MSG (
6575 " Timed out waiting " ,
@@ -94,8 +104,12 @@ bool UnboundBuffer::waitSend(int* rank, std::chrono::milliseconds timeout) {
94104 }
95105
96106 if (sendCompletions_ == 0 ) {
97- auto done = sendCv_.wait_for (
98- lock, timeout, [&] { return abortWaitSend_ || sendCompletions_ > 0 ; });
107+ auto done = sendCv_.wait_for (lock, timeout, [&] {
108+ if (gloo::_is_aborted ()) {
109+ abortWaitSend_ = true ;
110+ }
111+ return abortWaitSend_ || sendCompletions_ > 0 ;
112+ });
99113 if (!done) {
100114 throw ::gloo::IoException (GLOO_ERROR_MSG (
101115 " Timed out waiting " ,
0 commit comments