public async Task <string> ReadEntry(ulong address) { if (address.TrainId() != TrainId) { throw new InvalidOperationException("Wrong train ID"); } if (!initialized) { await Initialize(); } await semaphore.WaitAsync(); try { var bag = bagIdToBag[address.BagId()]; var entry = await bag.ReadEntry(address); return(entry); } finally { semaphore.Release(); } }
public async Task <string> ReadEntry(ulong address) { var baddr = new BucketAddress { TrainId = address.TrainId(), BagId = address.BagId(), BucketId = address.Index() / BagInfo.BagSettings.PerBucketMessages }; var bucket = await GetBucket(baddr); return(await bucket .GetEntry(address.Index() % BagInfo.BagSettings.PerBucketMessages)); }