File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -384,6 +384,10 @@ namespace photon
384384 thread* pop_front ()
385385 {
386386 auto ret = q[0 ];
387+ if (q.size () == 1 ) {
388+ q.pop_back ();
389+ return ret;
390+ }
387391 q[0 ] = q.back ();
388392 q[0 ]->idx = 0 ;
389393 q.pop_back ();
@@ -402,6 +406,11 @@ namespace photon
402406 }
403407
404408 auto id = obj->idx ;
409+ if (q.size () == 1 ) {
410+ assert (id == 0 );
411+ q.pop_back ();
412+ return 0 ;
413+ }
405414 q[obj->idx ] = q.back ();
406415 q[id]->idx = id;
407416 q.pop_back ();
@@ -419,6 +428,7 @@ namespace photon
419428 // compare m_nodes[idx] with parent node.
420429 bool up (int idx)
421430 {
431+ assert (!q.empty ());
422432 auto tmp = q[idx];
423433 bool ret = false ;
424434 while (idx != 0 ){
@@ -438,6 +448,7 @@ namespace photon
438448 // compare m_nodes[idx] with child node.
439449 bool down (int idx)
440450 {
451+ assert (!q.empty ());
441452 auto tmp = q[idx];
442453 size_t cmpIdx = (idx << 1 ) + 1 ;
443454 bool ret = false ;
You can’t perform that action at this time.
0 commit comments