File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,10 @@ namespace photon
391391 thread* pop_front ()
392392 {
393393 auto ret = q[0 ];
394+ if (q.size () == 1 ) {
395+ q.pop_back ();
396+ return ret;
397+ }
394398 q[0 ] = q.back ();
395399 q[0 ]->idx = 0 ;
396400 q.pop_back ();
@@ -409,6 +413,11 @@ namespace photon
409413 }
410414
411415 auto id = obj->idx ;
416+ if (q.size () == 1 ) {
417+ assert (id == 0 );
418+ q.pop_back ();
419+ return 0 ;
420+ }
412421 q[obj->idx ] = q.back ();
413422 q[id]->idx = id;
414423 q.pop_back ();
@@ -426,6 +435,7 @@ namespace photon
426435 // compare m_nodes[idx] with parent node.
427436 bool up (int idx)
428437 {
438+ assert (!q.empty ());
429439 auto tmp = q[idx];
430440 bool ret = false ;
431441 while (idx != 0 ){
@@ -445,6 +455,7 @@ namespace photon
445455 // compare m_nodes[idx] with child node.
446456 bool down (int idx)
447457 {
458+ assert (!q.empty ());
448459 auto tmp = q[idx];
449460 size_t cmpIdx = (idx << 1 ) + 1 ;
450461 bool ret = false ;
You can’t perform that action at this time.
0 commit comments