static void Main(string[] args) { var pool = new FlyweightObjectPool<byte[]>(() => new byte[65535]); pool.Allocate(1000); var buffer = pool.Dequeue(); // .. do something here .. pool.Enqueue(buffer); }
static void Main(string[] args) { var pool = new FlyweightObjectPool <byte[]>(() => new byte[65535]); pool.Allocate(1000); var buffer = pool.Dequeue(); // .. do something here .. pool.Enqueue(buffer); }
/// <summary> /// Initializes a new instance of the <see cref="MessageFactory"/> class. /// </summary> /// <param name="factory">Factory used to create headers.</param> public MessageFactory(HeaderFactory factory) { _factory = factory; _builders = new FlyweightObjectPool<MessageFactoryContext>(CreateBuilder); }
/// <summary> /// Initializes a new instance of the <see cref="MessageFactory"/> class. /// </summary> /// <param name="factory">Factory used to create headers.</param> public MessageFactory(HeaderFactory factory) { _factory = factory; _builders = new FlyweightObjectPool <MessageFactoryContext>(CreateBuilder); }