예제 #1
0
 virtual public Func <ChannelType, Task <int> > UseAsyncChannel()
 {
     if (_params.TrackServiceCallTimeouts)
     {
         // this func -
         return(async(channel) =>
         {
             // - track timeouts of -
             using (_timeoutTracker.StartTrackingOperation(channel))
             {
                 // - the test calls wrapped in timing tracking stats
                 return await _useChannelAsyncStats.CallAsyncFuncAndRecordStatsAsync(
                     () => UseAsyncChannelImpl()(channel),
                     RelaxedExceptionPolicy);
             }
         });
     }
     else
     {
         return(async(channel) =>
         {
             return await _useChannelAsyncStats.CallAsyncFuncAndRecordStatsAsync(
                 () => UseAsyncChannelImpl()(channel),
                 RelaxedExceptionPolicy);
         });
     }
 }
예제 #2
0
 virtual public Task CloseChannelAsync(ChannelType channel)
 {
     return(_params.PreemptiveCloseChannelTimeout > 0
         ? _closeChannelAsyncStats.CallAsyncFuncAndRecordStatsAsync(() =>
                                                                    TestHelpers.CloseChannelPreemptiveTimeoutAsync(channel, _params.PreemptiveCloseChannelTimeout, failOnPreemptiveTimeout: false), RelaxedExceptionPolicy)
         : _closeChannelAsyncStats.CallAsyncFuncAndRecordStatsAsync(() =>
                                                                    TestHelpers.CloseChannelAsync(channel), RelaxedExceptionPolicy));
 }
예제 #3
0
 virtual public Task CloseFactoryAsync(ChannelFactory <ChannelType> factory)
 {
     return(_params.PreemptiveCloseFactoryTimeout > 0
         ? _closeFactoryAsyncStats.CallAsyncFuncAndRecordStatsAsync(() =>
                                                                    TestHelpers.CloseFactoryPreemptiveTimeoutAsync(factory, _params.PreemptiveCloseFactoryTimeout, failOnPreemptiveTimeout: false), RelaxedExceptionPolicy)
         : _closeFactoryAsyncStats.CallAsyncFuncAndRecordStatsAsync(() =>
                                                                    TestHelpers.CloseFactoryAsync(factory), RelaxedExceptionPolicy));
 }
예제 #4
0
 virtual public Func <ChannelType, Task <int> > UseAsyncChannel()
 {
     return(async(channel) =>
     {
         using (StartTrackingOperation(channel))
         {
             return await _useChannelAsyncStats.CallAsyncFuncAndRecordStatsAsync(
                 () => UseAsyncChannelImpl(channel), RelaxedExceptionPolicy);
         }
     });
 }
 static RecyclablePooledFactoriesAndChannelsAsync_OpenOnce()
 {
     s_test = new TestTemplate();
     s_recyclablePooledFactoriesAndChannels = StaticDisposablesHelper.AddDisposable(
         new PoolOfAsyncThings <
             FactoryAndPoolOfItsAsyncObjects <ChannelFactory <ChannelType>, OpenAsyncOnceChannelWrapper <ChannelType> > >(
             maxSize: 3,     // # of pooled FactoryAndPoolOfItsChannels
             createInstance: () => new FactoryAndPoolOfItsAsyncObjects <ChannelFactory <ChannelType>, OpenAsyncOnceChannelWrapper <ChannelType> >(
                 createFactoryInstance:
                 s_test.CreateChannelFactory,
                 destroyFactoryInstanceAsync: async(chf) =>
                 await s_CloseFactoryStats.CallAsyncFuncAndRecordStatsAsync(s_test.CloseFactoryAsync, chf),
                 maxPooledObjects: 3,     // # of pooled channels within each pooled FactoryAndPoolOfItsAsyncObjects
                 createObject: (chf) =>
                 s_CreateChannelStats.CallFuncAndRecordStats(func: () => new OpenAsyncOnceChannelWrapper <ChannelType>(s_test.CreateChannel(chf))),
                 destroyObjectAsync: async(chWr) =>
                 await s_CloseChannelStats.CallAsyncFuncAndRecordStatsAsync(func: () => s_test.CloseChannelAsync(chWr.Channel))
                 ),
             destroyInstanceAsync: async(_fapoic) => await _fapoic.DestroyAsync()));
 }
        public static async Task UsePooledChannelsAsync()
        {
            var allTasks = new List <Task>();

            foreach (var factoryAndPoolOfItsChannels in s_recyclablePooledFactoriesAndChannels.GetAllPooledInstances())
            {
                foreach (var channelWrapper in factoryAndPoolOfItsChannels.ObjectsPool.GetAllPooledInstances())
                {
                    allTasks.Add(s_CallChannelStats.CallAsyncFuncAndRecordStatsAsync(async() =>
                    {
                        if (channelWrapper.Channel != null)
                        {
                            await channelWrapper.OpenChannelOnceAsync();
                            await s_test.UseAsyncChannel()(channelWrapper.Channel);
                            //Console.WriteLine(s);
                        }
                    }));
                }
            }
            await Task.WhenAll(allTasks);
        }
예제 #7
0
 virtual public Task OpenChannelAsync(ChannelType channel)
 {
     return(_openChannelAsyncStats.CallAsyncFuncAndRecordStatsAsync(() => TestHelpers.OpenChannelAsync(channel), RelaxedExceptionPolicy));
 }
예제 #8
0
 public Task CloseChannelAsync(ChannelType channel)
 {
     return(_closeChannelAsyncStats.CallAsyncFuncAndRecordStatsAsync(TestHelpers.CloseChannelAsync, channel, RelaxedExceptionPolicy));
 }
예제 #9
0
 public Task CloseFactoryAsync(ChannelFactory <ChannelType> factory)
 {
     return(_closeFactoryAsyncStats.CallAsyncFuncAndRecordStatsAsync(TestHelpers.CloseFactoryAsync, factory, RelaxedExceptionPolicy));
 }