You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've having problems with my code that disappear when I change the implementation of the "channel" class I am using from using a promise/future pair to using a semaphore. When using the promise/future implementation, I get unexpected hangs, crashes, and other problems, but when I use the semaphore implementation, these problems go away (the code still hangs during output and at startup sometimes but I think that is a different issue). The promise/future implementation of the channel class is here: https://github.com/dmarce1/FVFMM/blob/master/src/channel.hpp
and the new implementation that seems to get rid of problems is
#ifndef CHANNEL_HPP_
#define CHANNEL_HPP_
#include "defs.hpp"
template<class T>
class channel {
private:
hpx::lcos::local::counting_semaphore signal;
T data;
std::atomic<bool> full;
public:
channel() : full(false){
}
~channel() = default;
channel(const channel&) = delete;
channel(channel&& other ) = delete;
channel& operator=(channel&& other ) = delete;
template<class U>
void set_value( U value ) {
assert(!full);
data = std::move(value);
full = true;
signal.signal();
}
T get() {
signal.wait();
assert(full);
full = false;
return data;
}
};
#endif /* CHANNEL_HPP_ */
Using the promise/future implementation seems to have also called problems for other calls to the future class functions, even on futures not produced from a promise. For instance, calls to future::wait_for and future::wait_until would act weird, issuing timeouts as if the timing had started when the program was initiated rather than when wait_for/until was called - and for futures not created with a promise. These problems disappeared when I changed channel implementations.
I will try and reproduce the problem with a smaller code.
The text was updated successfully, but these errors were encountered:
I think I was wrong on this one. I get hangs and crashes even with the semaphore version of my channel, and the trap I had written to detect if the promise/future channel had a bug in it, itself, had a bug. I've also determined the problem with wait_for occurs even in a simple test code.
I've having problems with my code that disappear when I change the implementation of the "channel" class I am using from using a promise/future pair to using a semaphore. When using the promise/future implementation, I get unexpected hangs, crashes, and other problems, but when I use the semaphore implementation, these problems go away (the code still hangs during output and at startup sometimes but I think that is a different issue). The promise/future implementation of the channel class is here:
https://github.com/dmarce1/FVFMM/blob/master/src/channel.hpp
and the new implementation that seems to get rid of problems is
Using the promise/future implementation seems to have also called problems for other calls to the future class functions, even on futures not produced from a promise. For instance, calls to future::wait_for and future::wait_until would act weird, issuing timeouts as if the timing had started when the program was initiated rather than when wait_for/until was called - and for futures not created with a promise. These problems disappeared when I changed channel implementations.
I will try and reproduce the problem with a smaller code.
The text was updated successfully, but these errors were encountered: