mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 02:18:04 +01:00
Fix hang in destructor
Consider following situation. A class owns a timer. In destructor of that class we call .cancel() asynchronous on timer before it's destruction. Now timer is executing cancel in it's own internal thread, while it's doing that destructor of timer is called from owner's destructor. Timer destructor enqueues stop notification. If that enqueue is happening just after while loop from cancel notification, stop notification is gonna be dropped and timer will never stop. Fix: Add new method in TimedNotificationQueue which will return a notification regardless of the time it needs to be executed. Get number of pending tasks in the queue. Flush out that many notifications from queue while taking special consideration of pending Stop and Cancel notifications. Add test for new method in TimedNotificationQueue and fix cancel all tests to actually check if notification got executed. fixes #3986
This commit is contained in:
@@ -89,6 +89,16 @@ public:
|
||||
/// assigned to a Notification::Ptr, to avoid potential
|
||||
/// memory management issues.
|
||||
|
||||
Notification* dequeueNextNotification();
|
||||
/// Dequeues the next notification regardless of timestamp.
|
||||
/// Returns 0 (null) if no notification is available.
|
||||
/// The caller gains ownership of the notification and
|
||||
/// is expected to release it when done with it.
|
||||
///
|
||||
/// It is highly recommended that the result is immediately
|
||||
/// assigned to a Notification::Ptr, to avoid potential
|
||||
/// memory management issues.
|
||||
|
||||
Notification* waitDequeueNotification();
|
||||
/// Dequeues the next pending notification.
|
||||
/// If no notification is available, waits for a notification
|
||||
|
||||
Reference in New Issue
Block a user