The current implementation of the waiting for the CheckOutProgress and CheckInProgress threads to finish, causes a race condition, which can lead to Osmosis not finishing forever); The stop method of CheckOutProgress (which is supposed to be called by someone other than the thread itself, who wants to stop the thread) calls notify_one on the 'stop' condition variable, which is used by the CheckOutProgress thread to wait for a stop command.
But, In case that the checkout was really short in duration, then the CheckOutThread hasn't started waiting on the condition variable, which means that notify_on has no effect at all. notify_one only works when it is invoked -after- someone has started waiting on the condition variable, and not before (i was supprised too. here is someone with the same problem: http://stackoverflow.com/questions/18691966/are-there-alternative-ways-to-catch-potentially-missed-signals-with-condition-va).
In case that the notify_on was missed, then the waiting on the condition variable will be forever (actually terminated after a timeout period and then started again, in a loop).
The current implementation of the waiting for the CheckOutProgress and CheckInProgress threads to finish, causes a race condition, which can lead to Osmosis not finishing forever); The
stop
method ofCheckOutProgress
(which is supposed to be called by someone other than the thread itself, who wants to stop the thread) callsnotify_one
on the 'stop' condition variable, which is used by theCheckOutProgress
thread to wait for a stop command. But, In case that the checkout was really short in duration, then theCheckOutThread
hasn't started waiting on the condition variable, which means thatnotify_on
has no effect at all.notify_one
only works when it is invoked -after- someone has started waiting on the condition variable, and not before (i was supprised too. here is someone with the same problem: http://stackoverflow.com/questions/18691966/are-there-alternative-ways-to-catch-potentially-missed-signals-with-condition-va). In case that thenotify_on
was missed, then the waiting on the condition variable will be forever (actually terminated after a timeout period and then started again, in a loop).