Browse Source

!12 注释没使用到的代码

tags/v1.1.0
微希夷 yitter 3 years ago
parent
commit
bdb9fd2c14
4 changed files with 48 additions and 48 deletions
  1. +15
    -15
      Go/source/idgen/SnowWorkerM1.go
  2. +16
    -16
      PHP/src/snowflake/snowflake.c
  3. +2
    -2
      PHP/src/snowflake/snowflake.h
  4. +15
    -15
      zzz-OtherLanguages/V/source/core/SnowWorkerM1.v

+ 15
- 15
Go/source/idgen/SnowWorkerM1.go View File

@@ -28,8 +28,8 @@ type SnowWorkerM1 struct {
_TurnBackIndex byte
_IsOverCost bool
_OverCostCountInOneTerm uint32
_GenCountInOneTerm uint32
_TermIndex uint32
// _GenCountInOneTerm uint32
// _TermIndex uint32

sync.Mutex
}
@@ -100,8 +100,8 @@ func NewSnowWorkerM1(options *IdGeneratorOptions) ISnowWorker {
_TurnBackIndex: 0,
_IsOverCost: false,
_OverCostCountInOneTerm: 0,
_GenCountInOneTerm: 0,
_TermIndex: 0,
// _GenCountInOneTerm: 0,
// _TermIndex: 0,
}
}

@@ -115,9 +115,9 @@ func (m1 *SnowWorkerM1) BeginOverCostAction(useTimeTick int64) {
}

func (m1 *SnowWorkerM1) EndOverCostAction(useTimeTick int64) {
if m1._TermIndex > 10000 {
m1._TermIndex = 0
}
// if m1._TermIndex > 10000 {
// m1._TermIndex = 0
// }
}

func (m1 *SnowWorkerM1) BeginTurnBackAction(useTimeTick int64) {
@@ -131,21 +131,21 @@ func (m1 *SnowWorkerM1) EndTurnBackAction(useTimeTick int64) {
func (m1 *SnowWorkerM1) NextOverCostId() int64 {
currentTimeTick := m1.GetCurrentTimeTick()
if currentTimeTick > m1._LastTimeTick {
m1.EndOverCostAction(currentTimeTick)
// m1.EndOverCostAction(currentTimeTick)
m1._LastTimeTick = currentTimeTick
m1._CurrentSeqNumber = m1.MinSeqNumber
m1._IsOverCost = false
m1._OverCostCountInOneTerm = 0
m1._GenCountInOneTerm = 0
// m1._GenCountInOneTerm = 0
return m1.CalcId(m1._LastTimeTick)
}
if m1._OverCostCountInOneTerm >= m1.TopOverCostCount {
m1.EndOverCostAction(currentTimeTick)
// m1.EndOverCostAction(currentTimeTick)
m1._LastTimeTick = m1.GetNextTimeTick()
m1._CurrentSeqNumber = m1.MinSeqNumber
m1._IsOverCost = false
m1._OverCostCountInOneTerm = 0
m1._GenCountInOneTerm = 0
// m1._GenCountInOneTerm = 0
return m1.CalcId(m1._LastTimeTick)
}
if m1._CurrentSeqNumber > m1.MaxSeqNumber {
@@ -153,12 +153,12 @@ func (m1 *SnowWorkerM1) NextOverCostId() int64 {
m1._CurrentSeqNumber = m1.MinSeqNumber
m1._IsOverCost = true
m1._OverCostCountInOneTerm++
m1._GenCountInOneTerm++
// m1._GenCountInOneTerm++

return m1.CalcId(m1._LastTimeTick)
}

m1._GenCountInOneTerm++
// m1._GenCountInOneTerm++
return m1.CalcId(m1._LastTimeTick)
}

@@ -195,12 +195,12 @@ func (m1 *SnowWorkerM1) NextNormalId() int64 {

if m1._CurrentSeqNumber > m1.MaxSeqNumber {
m1.BeginOverCostAction(currentTimeTick)
m1._TermIndex++
// m1._TermIndex++
m1._LastTimeTick++
m1._CurrentSeqNumber = m1.MinSeqNumber
m1._IsOverCost = true
m1._OverCostCountInOneTerm = 1
m1._GenCountInOneTerm = 1
// m1._GenCountInOneTerm = 1

return m1.CalcId(m1._LastTimeTick)
}


+ 16
- 16
PHP/src/snowflake/snowflake.c View File

@@ -8,7 +8,7 @@
#include "windows.h"
#endif

static void EndOverCostAction(uint64_t useTimeTick, snowflake *flake);
// static void EndOverCostAction(uint64_t useTimeTick, snowflake *flake);
static inline uint64_t NextOverCostId(snowflake *flake);
static inline uint64_t NextNormalId(snowflake *flake);
static inline uint64_t GetCurrentTimeTick(snowflake *flake);
@@ -121,35 +121,35 @@ void Config(snowflake *flake)
flake->Method = flake->Method;
}

static inline void EndOverCostAction(uint64_t useTimeTick, snowflake *flake)
{
if (flake->_TermIndex > 10000)
{
flake->_TermIndex = 0;
}
}
// static inline void EndOverCostAction(uint64_t useTimeTick, snowflake *flake)
// {
// if (flake->_TermIndex > 10000)
// {
// flake->_TermIndex = 0;
// }
// }

static inline uint64_t NextOverCostId(snowflake *flake)
{
uint64_t currentTimeTick = GetCurrentTimeTick(flake);
if (currentTimeTick > flake->_LastTimeTick)
{
EndOverCostAction(currentTimeTick, flake);
// EndOverCostAction(currentTimeTick, flake);
flake->_LastTimeTick = currentTimeTick;
flake->_CurrentSeqNumber = flake->MinSeqNumber;
flake->_IsOverCost = 0;
flake->_OverCostCountInOneTerm = 0;
flake->_GenCountInOneTerm = 0;
// flake->_GenCountInOneTerm = 0;
return CalcId(flake);
}
if (flake->_OverCostCountInOneTerm > flake->TopOverCostCount)
{
EndOverCostAction(currentTimeTick, flake);
// EndOverCostAction(currentTimeTick, flake);
flake->_LastTimeTick = GetNextTimeTick(flake);
flake->_CurrentSeqNumber = flake->MinSeqNumber;
flake->_IsOverCost = 0;
flake->_OverCostCountInOneTerm = 0;
flake->_GenCountInOneTerm = 0;
// flake->_GenCountInOneTerm = 0;
return CalcId(flake);
}
if (flake->_CurrentSeqNumber > flake->MaxSeqNumber)
@@ -158,11 +158,11 @@ static inline uint64_t NextOverCostId(snowflake *flake)
flake->_CurrentSeqNumber = flake->MinSeqNumber;
flake->_IsOverCost = 1;
flake->_OverCostCountInOneTerm++;
flake->_GenCountInOneTerm++;
// flake->_GenCountInOneTerm++;
return CalcId(flake);
}

flake->_GenCountInOneTerm++;
// flake->_GenCountInOneTerm++;
return CalcId(flake);
}

@@ -194,12 +194,12 @@ static inline uint64_t NextNormalId(snowflake *flake)
}
if (flake->_CurrentSeqNumber > flake->MaxSeqNumber)
{
flake->_TermIndex++;
// flake->_TermIndex++;
flake->_LastTimeTick++;
flake->_CurrentSeqNumber = flake->MinSeqNumber;
flake->_IsOverCost = 1;
flake->_OverCostCountInOneTerm = 1;
flake->_GenCountInOneTerm = 1;
// flake->_GenCountInOneTerm = 1;
return CalcId(flake);
}
return CalcId(flake);


+ 2
- 2
PHP/src/snowflake/snowflake.h View File

@@ -18,8 +18,8 @@ typedef struct snowflake
uint8_t _TurnBackIndex;
uint8_t _IsOverCost;
uint32_t _OverCostCountInOneTerm;
uint32_t _GenCountInOneTerm;
uint32_t _TermIndex;
// uint32_t _GenCountInOneTerm;
// uint32_t _TermIndex;
volatile unsigned int _Lock;
} snowflake;



+ 15
- 15
zzz-OtherLanguages/V/source/core/SnowWorkerM1.v View File

@@ -25,8 +25,8 @@ mut:
turnback_index byte
is_over_cost bool
overcostcount_inoneterm u32
gencount_inoneterm u32
term_index u32
// gencount_inoneterm u32
// term_index u32
}

pub fn make_sf_m1(options &contract.IdGeneratorOptions) &contract.ISnowWorker {
@@ -78,11 +78,11 @@ pub fn make_sf_m1(options &contract.IdGeneratorOptions) &contract.ISnowWorker {

// }

fn (mut m1 SnowWorkerM1) end_over_cost_action() {
if m1.term_index > 10000 {
m1.term_index = 0
}
}
// fn (mut m1 SnowWorkerM1) end_over_cost_action() {
// if m1.term_index > 10000 {
// m1.term_index = 0
// }
// }

// fn (m1 &SnowWorkerM1) begin_turn_back_action(use_time_tick i64) {

@@ -95,21 +95,21 @@ fn (mut m1 SnowWorkerM1) end_over_cost_action() {
fn (mut m1 SnowWorkerM1) next_over_cost_id() u64 {
current_time_tick := m1.get_current_time_tick()
if current_time_tick > m1.last_time_tick {
m1.end_over_cost_action()
// m1.end_over_cost_action()
m1.last_time_tick = current_time_tick
m1.current_seqnumber = m1.min_seqnumber
m1.is_over_cost = false
m1.overcostcount_inoneterm = 0
m1.gencount_inoneterm = 0
// m1.gencount_inoneterm = 0
return m1.calc_id()
}
if m1.overcostcount_inoneterm >= m1.top_over_cost_count {
m1.end_over_cost_action()
// m1.end_over_cost_action()
m1.last_time_tick = m1.get_next_time_tick()
m1.current_seqnumber = m1.min_seqnumber
m1.is_over_cost = false
m1.overcostcount_inoneterm = 0
m1.gencount_inoneterm = 0
// m1.gencount_inoneterm = 0
return m1.calc_id()
}
if m1.current_seqnumber > m1.max_seqnumber {
@@ -117,11 +117,11 @@ fn (mut m1 SnowWorkerM1) next_over_cost_id() u64 {
m1.current_seqnumber = m1.min_seqnumber
m1.is_over_cost = true
m1.overcostcount_inoneterm++
m1.gencount_inoneterm++
// m1.gencount_inoneterm++

return m1.calc_id()
}
m1.gencount_inoneterm++
// m1.gencount_inoneterm++
return m1.calc_id()
}

@@ -152,12 +152,12 @@ fn (mut m1 SnowWorkerM1) next_normal_id() u64 {
}
if m1.current_seqnumber > m1.max_seqnumber {
// m1.begin_over_cost_action(current_time_tick)
m1.term_index++
// m1.term_index++
m1.last_time_tick++
m1.current_seqnumber = m1.min_seqnumber
m1.is_over_cost = true
m1.overcostcount_inoneterm = 1
m1.gencount_inoneterm = 1
// m1.gencount_inoneterm = 1

return m1.calc_id()
}


Loading…
Cancel
Save