File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -503,12 +503,18 @@ void handleNotification(NotifInfo *notif)
503503void async_cb_handler (uv_async_t *handle)
504504// ===================================================================
505505{
506- NotifInfo *notif;
507-
508- mutex::scoped_lock sl (zqueue_mutex);
509-
510- while (!zqueue.empty ()) {
511- notif = zqueue.front ();
506+ NotifInfo* notif;
507+ std::queue<NotifInfo*> notifications;
508+ // consume all the queued notifications
509+ {
510+ mutex::scoped_lock sl (zqueue_mutex);
511+ // http://media2.giphy.com/media/MS0fQBmGGMaRy/giphy.gif
512+ swap (notifications, zqueue);
513+ }
514+ // process notifications
515+ while (!notifications.empty ()) {
516+ notif = notifications.front ();
517+ notifications.pop ();
512518#if OPENZWAVE_SECURITY != 1
513519 if (notif->homeid == 0 ) {
514520 handleControllerCommand (notif);
@@ -518,8 +524,6 @@ void async_cb_handler(uv_async_t *handle)
518524#else
519525 handleNotification (notif);
520526#endif
521- delete notif;
522- zqueue.pop ();
523527 }
524528}
525529
You can’t perform that action at this time.
0 commit comments