| 449 | } |
| 450 | |
| 451 | func (d *NapiGoInstanceAsyncWorkData) insert( |
| 452 | execute AsyncExecuteCallback, |
| 453 | complete AsyncCompleteCallback, |
| 454 | ) *NapiGoAsyncWorkMapEntry { |
| 455 | // callers are expected to lock |
| 456 | |
| 457 | if d.AsyncWorkMap == nil { |
| 458 | d.AsyncWorkMap = NapiGoInstanceAsyncWorkMap{} |
| 459 | } |
| 460 | |
| 461 | for { |
| 462 | id := d.NextID |
| 463 | d.NextID++ |
| 464 | |
| 465 | if d.AsyncWorkMap[id] == nil { |
| 466 | result := &NapiGoAsyncWorkMapEntry{ |
| 467 | Execute: execute, |
| 468 | Complete: complete, |
| 469 | ID: id, |
| 470 | } |
| 471 | d.AsyncWorkMap[id] = result |
| 472 | return result |
| 473 | } |
| 474 | } |
| 475 | } |