File tree 1 file changed +20
-1
lines changed 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -479,18 +479,21 @@ namespace kit
479
479
}
480
480
481
481
unsigned add (std::shared_ptr<T> val) {
482
+ auto l = this ->lock ();
482
483
unsigned id = next ();
483
484
m_Group[id] = val;
484
485
return id;
485
486
}
486
487
487
488
bool add (unsigned id, std::shared_ptr<T> val) {
489
+ auto l = this ->lock ();
488
490
m_Group[id] = val;
489
491
return true ;
490
492
}
491
493
492
494
unsigned remove_if (std::function<bool (const std::shared_ptr<T>&)> func)
493
495
{
496
+ auto l = this ->lock ();
494
497
unsigned count = 0 ;
495
498
for (auto itr = m_Group.begin ();
496
499
itr != m_Group.end ();
@@ -504,6 +507,15 @@ namespace kit
504
507
}
505
508
return count;
506
509
}
510
+ void clear (unsigned idx) {
511
+ auto l = this ->lock ();
512
+ try {
513
+ m_Reserved.erase (idx);
514
+ }catch (const std::out_of_range&){}
515
+ try {
516
+ erase (idx);
517
+ }catch (const std::out_of_range&){}
518
+ }
507
519
void clear () {
508
520
auto l = this ->lock ();
509
521
m_Unused=0 ;
@@ -538,21 +550,28 @@ namespace kit
538
550
return m_Unused-1 ;
539
551
}
540
552
541
- unsigned reserve () { return next (); } // DEPRECATED
553
+ unsigned reserve () {
554
+ auto l = this ->lock ();
555
+ return next ();
556
+ } // DEPRECATED
542
557
543
558
void reserve (unsigned idx){
559
+ auto l = this ->lock ();
544
560
m_Reserved.insert (idx);
545
561
}
546
562
unsigned reserve_next () {
563
+ auto l = this ->lock ();
547
564
unsigned id = next ();
548
565
reserve (id);
549
566
return id;
550
567
}
551
568
bool is_reserved (unsigned idx) const {
569
+ auto l = this ->lock ();
552
570
return m_Reserved.find (idx) != m_Reserved.end ();
553
571
}
554
572
555
573
bool has (unsigned idx) {
574
+ auto l = this ->lock ();
556
575
return m_Group.find (idx) != m_Group.end ();
557
576
}
558
577
You can’t perform that action at this time.
0 commit comments