newId generates a random unique task ID. logMu must be acquired before calling this function. The format of this is: 32 bits: raft ID 32 bits: random number
()
| 289 | // 32 bits: raft ID |
| 290 | // 32 bits: random number |
| 291 | func (t *tasks) newId() uint64 { |
| 292 | myRaftId := State.WALstore.Uint(raftwal.RaftId) |
| 293 | for { |
| 294 | id := myRaftId<<32 | uint64(t.rng.Uint32()) |
| 295 | // z.Tree cannot store 0 or math.MaxUint64. Check that id is unique. |
| 296 | if id != 0 && id != math.MaxUint64 && t.log.Get(id) == 0 { |
| 297 | return id |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | type taskRequest struct { |
| 303 | id uint64 |