File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -356,6 +356,10 @@ namespace photon
356356 thread* pop_front ()
357357 {
358358 auto ret = q[0 ];
359+ if (q.size () == 1 ) {
360+ q.pop_back ();
361+ return ret;
362+ }
359363 q[0 ] = q.back ();
360364 q[0 ]->idx = 0 ;
361365 q.pop_back ();
@@ -374,6 +378,11 @@ namespace photon
374378 }
375379
376380 auto id = obj->idx ;
381+ if (q.size () == 1 ) {
382+ assert (id == 0 );
383+ q.pop_back ();
384+ return 0 ;
385+ }
377386 q[obj->idx ] = q.back ();
378387 q[id]->idx = id;
379388 q.pop_back ();
@@ -391,6 +400,7 @@ namespace photon
391400 // compare m_nodes[idx] with parent node.
392401 bool up (int idx)
393402 {
403+ assert (!q.empty ());
394404 auto tmp = q[idx];
395405 bool ret = false ;
396406 while (idx != 0 ){
@@ -410,6 +420,7 @@ namespace photon
410420 // compare m_nodes[idx] with child node.
411421 bool down (int idx)
412422 {
423+ assert (!q.empty ());
413424 auto tmp = q[idx];
414425 size_t cmpIdx = (idx << 1 ) + 1 ;
415426 bool ret = false ;
You can’t perform that action at this time.
0 commit comments