public static void Main(string[] args) { var actor = new ListActor(); for (int count = 0; count < 1000; count++) { var messageRegion = RegionAllocator.AllocateRegion(2000000); var oneMsgList = new RegionList <Item>(messageRegion); for (int j = 0; j < 2000000 / 32; j++) { var item = new Item(messageRegion, 1, 1); oneMsgList.Add(item); } actor.OnRecv(messageRegion, oneMsgList); } }
public void OnRecv(Region messageRegion, RegionList <Item> list) { var newItemList = new ItemList(_actorRegion, list); _list.Add(newItemList); _recvCount++; if (_recvCount % 5 == 0) { try { var itemList = _list.RemoveAtAndGet(_list.Count - 3); RegionAllocator.FreeRegion(itemList.List.region); } catch (Exception) { } } }
public ListActor() { _actorRegion = RegionAllocator.AllocateRegion(64000); _list = new RegionList <ItemList>(_actorRegion); }
public ItemList(Region region, RegionList <Item> list) { _list = list; }