« first day (1899 days earlier)      last day (960 days later) » 

3:27 AM
The signals produced by `conditional_variable::singal_one()` may be lost?

Here is the pseudocode:
//global variable(a bad idea to use global variables, just for demo)
std::conditional_variable cv;
std::mutext lk;
bool ready = false;


//the single consumer thread
std::unique_lock(lk);
cv.wait(lk, [=](){return flag;});
ready = false;
//do some processing, for example need 2 seconds; it's slower than the producer, so the singnals may be lost now and then.

//the single producer thread
std::unique_lock(lk);
 
 
5 hours later…
8:14 AM
@John I'm not sure what you mean. The "signal_one" is only guaranteed to do something if at that very moment something is actively waiting for that condition_variable
if you want something like semaphore that says "consumable is ready for now or later" then use a semaphore, not just condition variable
 
8:41 AM
I see. But semaphore is not supported by C++11.
 
you can use a library for that. There's plenty of semaphore implementations out there
don't use the wrong synchronization primitive for the job, just because it's not in the standard library
 
 
2 hours later…
11:11 AM
I see. Thank you so much.
 
 
8 hours later…
7:24 PM
Test* t = new Test;
int x[2];
func(t); // IDE warns: Local variable 't' may point to deallocated memory
If I remove int x[2];, I don't get that error. Why is that?
ah nvm, seems to be a function call before hand
 
I was about to say, what kind of IDE is that
 
4 messages moved from Lounge<C++>
 
 
2 hours later…
9:20 PM
@PeterT The broken kind?
 

« first day (1899 days earlier)      last day (960 days later) »