public static void UsePooledChannels() { foreach (var factoryAndPoolOfItsChannels in s_recyclablePooledFactoriesAndChannels.GetAllPooledInstances()) { foreach (var channel in factoryAndPoolOfItsChannels.ObjectsPool.GetAllPooledInstances()) { s_test.UseChannel()(channel); } } }
public static void UsePooledChannels() { foreach (var factoryAndPoolOfItsChannels in s_recyclablePooledFactoriesAndChannels.GetAllPooledInstances()) { foreach (var channel in factoryAndPoolOfItsChannels.ObjectsPool.GetAllPooledInstances()) { s_CallChannelStats.CallActionAndRecordStats(() => { s_test.UseChannel()(channel); }); } } }
public static int UsePooledChannels() { int requestsMade = 0; foreach (var factoryAndPoolOfItsChannels in s_recyclablePooledFactoriesAndChannels.GetAllPooledInstances()) { foreach (var channel in factoryAndPoolOfItsChannels.ObjectsPool.GetAllPooledInstances()) { requestsMade += s_test.UseChannel()(channel); } } return(requestsMade); }
public static void CreateFactoriesAndChannelsUseAllOnceCloseAll() { using (var theOneTimeThing = new PoolOfThings <FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, ChannelType> >( maxSize: 3, // # of pooled FactoryAndPoolOfItsObjects createInstance: () => new FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, ChannelType>( createFactoryInstance: () => s_test.CreateChannelFactory(), destroyFactoryInstance: (chf) => s_CloseFactoryStats.CallActionAndRecordStats(() => s_test.CloseFactory(chf)), maxPooledObjects: 3, // # of pooled channels within each pooled FactoryAndPoolOfItsObjects createObject: (chf) => s_CreateChannelStats.CallFuncAndRecordStats(func: () => s_test.CreateChannel(chf)), destroyObject: (ch) => s_CloseChannelStats.CallActionAndRecordStats(() => s_test.CloseChannel(ch)) ), destroyInstance: (_fapoic) => _fapoic.Destroy())) { foreach (var factoryAndPoolOfItsChannels in theOneTimeThing.GetAllPooledInstances()) { foreach (var channel in factoryAndPoolOfItsChannels.ObjectsPool.GetAllPooledInstances()) { s_CallChannelStats.CallActionAndRecordStats(() => { s_test.UseChannel()(channel); }); } } } }
// A full cycle of creating a pool of channel factories, using each factory to create // a pool of channels, using all channels once and then closing all of them public static void CreateFactoriesAndChannelsUseAllOnceCloseAll() { using (var theOneTimeThing = new PoolOfThings <FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, ChannelType> >( maxSize: s_test.TestParameters.MaxPooledFactories, // # of pooled FactoryAndPoolOfItsObjects createInstance: () => new FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, ChannelType>( createFactoryInstance: () => s_test.CreateChannelFactory(), destroyFactoryInstance: (chf) => s_test.CloseFactory(chf), maxPooledObjects: s_test.TestParameters.MaxPooledChannels, // # of pooled channels within each pooled FactoryAndPoolOfItsObjects createObject: (chf) => s_test.CreateChannel(chf), destroyObject: (ch) => s_test.CloseChannel(ch)), destroyInstance: (_fapoio) => _fapoio.Destroy())) { foreach (var factoryAndPoolOfItsChannels in theOneTimeThing.GetAllPooledInstances()) { foreach (var channel in factoryAndPoolOfItsChannels.ObjectsPool.GetAllPooledInstances()) { s_test.UseChannel()(channel); } } } }
// A full cycle of creating a pool of channel factories, using each factory to create // a pool of channels, using all channels once and then closing all of them public static int CreateFactoriesAndChannelsUseAllOnceCloseAll() { using (var theOneTimeThing = new PoolOfThings <FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, ChannelType> >( maxSize: s_test.TestParameters.MaxPooledFactories, // # of pooled FactoryAndPoolOfItsObjects createInstance: () => new FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, ChannelType>( createFactoryInstance: () => s_test.CreateChannelFactory(), destroyFactoryInstance: (chf) => s_test.CloseFactory(chf), maxPooledObjects: s_test.TestParameters.MaxPooledChannels, // # of pooled channels within each pooled FactoryAndPoolOfItsObjects createObject: (chf) => s_test.CreateChannel(chf), destroyObject: (ch) => s_test.CloseChannel(ch), validateObjectInstance: s_test.ValidateChannel), destroyInstance: (fapoio) => fapoio.Destroy(), instanceValidator: (fapoio) => s_test.ValidateFactory(fapoio.Factory))) { int requestsMade = 0; foreach (var factoryAndPoolOfItsChannels in theOneTimeThing.GetAllPooledInstances()) { foreach (var channel in factoryAndPoolOfItsChannels.ObjectsPool.GetAllPooledInstances()) { requestsMade += s_test.UseChannel()(channel); } } return(requestsMade); } }
public static void CreateUseAndCloseChannels() { foreach (var factory in s_pooledChannelFactories.GetAllPooledInstances()) { ChannelType channel = s_test.CreateChannel(factory); if (channel != null) { s_test.UseChannel()(channel); s_test.CloseChannel(channel); } } }
public static int CreateUseAndCloseChannels() { int requestsMade = 0; foreach (var factory in s_pooledChannelFactories.GetAllPooledInstances()) { ChannelType channel = s_test.CreateChannel(factory); if (channel != null) { requestsMade += s_test.UseChannel()(channel); s_test.CloseChannel(channel); } } return(requestsMade); }
public static void CreateUseAndCloseChannels() { foreach (var factory in s_pooledChannelFactories.GetAllPooledInstances()) { ChannelType channel = null; s_CreateChannelStats.CallActionAndRecordStats(() => channel = s_test.CreateChannel(factory)); if (channel != null) { s_CallChannelStats.CallActionAndRecordStats(() => s_test.UseChannel()(channel)); s_CloseChannelStats.CallActionAndRecordStats(() => s_test.CloseChannel(channel)); } } }