MCPcopy Create free account
hub / github.com/dds-bridge/dds / GetNumber

Method GetNumber

library/src/system/scheduler.cpp:763–842  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

761
762
763schedType Scheduler::GetNumber(const int thrId)
764{
765 const unsigned tu = static_cast<unsigned>(thrId);
766 int g = threadGroup[tu];
767 listType * lp;
768 schedType st;
769
770 if (g == -1)
771 {
772 // Find a new group
773
774 if (currGroup >= numGroups - 1)
775 {
776 // Out of groups. Just an optimization not to touch the
777 // shared variable unnecessarily.
778 st.number = -1;
779 return st;
780 }
781
782 // Atomic.
783 g = ++currGroup;
784
785 if (g >= numGroups)
786 {
787 // Out of groups. currGroup could have changed in the
788 // meantime in another thread, so test again.
789
790 st.number = -1;
791 return st;
792 }
793
794 // A bit inelegant to duplicate this, but seems better than
795 // the alternative, as threadGroup must get set to -1 in some
796 // cases.
797 threadGroup[tu] = g;
798 threadCurrGroup[tu] = g;
799 group[g].repeatNo = 0;
800 group[g].actual = 0;
801 }
802
803 // Continue with existing or new group
804
805 int strain = group[g].strain;
806 int key = group[g].hash;
807
808 lp = &list[strain][key];
809 st.number = lp->first;
810 lp->first = hands[lp->first].next;
811
812 if (group[g].repeatNo == 0)
813 {
814 group[g].head = st.number;
815 st.repeatOf = -1;
816
817 // Only first-solve suited hands for statistics right now.
818 hands[st.number].selectFlag =
819 (hands[st.number].strain == 4 ? 1 : 0);
820 }

Callers 3

play_chunk_commonFunction · 0.80
solve_chunk_commonFunction · 0.80
calc_chunk_commonFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected