github.com/annchain/OG@v0.0.9/og/message_archive/message_counter.go (about)

     1  package message_archive
     2  
     3  import "sync/atomic"
     4  
     5  type MessageCounter struct {
     6  	requestId uint32
     7  }
     8  
     9  //get current request id
    10  func (m *MessageCounter) Get() uint32 {
    11  	if m.requestId > uint32(1<<30) {
    12  		atomic.StoreUint32(&m.requestId, 10)
    13  	}
    14  	return atomic.AddUint32(&m.requestId, 1)
    15  }
    16  
    17  func MsgCountInit() {
    18  	MsgCounter = &MessageCounter{
    19  		requestId: 1,
    20  	}
    21  }