modulecoreimportcontractstructSnowWorkerM2{SnowWorkerM1}pubfnmake_sf_m2(options&contract.IdGeneratorOptions)&contract.ISnowWorker{m1:=make_sf_m1(options)ifm1isSnowWorkerM1{return&SnowWorkerM2{m1}}return&SnowWorkerM2{}}pubfn(mutm2SnowWorkerM2)next_id()u64{m2.mu.@lock()mutcurrent_time_tick:=m2.get_current_time_tick()ifm2.last_time_tick==current_time_tick{m2.current_seqnumber=(m2.current_seqnumber+1)&m2.max_seqnumberifm2.current_seqnumber==0{m2.current_seqnumber=m2.min_seqnumbercurrent_time_tick=m2.get_next_time_tick()}}else{m2.current_seqnumber=m2.min_seqnumber}ifcurrent_time_tick<m2.last_time_tick{println("Time error for "+(m2.last_time_tick-current_time_tick).str()+" milliseconds")}m2.last_time_tick=current_time_tickid:=u64(current_time_tick<<m2.timestamp_shift)|u64(m2.worker_id<<m2.seq_bitlength)|u64(m2.current_seqnumber)m2.mu.unlock()returnid}