コード例 #1
0
 /// <summary>
 /// Creates a new <see cref="PooledDbConnection"/> for the <see cref="_pool"/>.
 /// </summary>
 /// <param name="objectPool">The owner object pool.</param>
 /// <returns>A new <see cref="PooledDbConnection"/> for the <see cref="_pool"/>.</returns>
 PooledDbConnection CreateNewObj(IObjectPool<PooledDbConnection> objectPool)
 {
     var ret = new PooledDbConnection(this);
     var conn = CreateConnection(ConnectionString);
     ret.SetConnection(conn);
     return ret;
 }
コード例 #2
0
 public EntityManager(
     IChannelManager channelManager,
     IObjectPool<IEntity> objectPool)
 {
     _channelManager = channelManager;
     _entityPool = objectPool;
 }
 public void BeginTest()
 {
     repo = new MockRepository();
     channelCreator = repo.StrictMock<ICanCreateChannels<IService>>();
     poolFactory = repo.StrictMock<IPoolFactory>();
     pool = repo.StrictMock<IObjectPool>();
     Expect.Call(poolFactory.CreatePool(null)).IgnoreArguments().Return(pool);
     LastCall.IgnoreArguments();
 }
コード例 #4
0
 /// <summary>
 ///   Inietta le dipendenze.
 /// </summary>
 /// <param name="log">Il log.</param>
 /// <param name="cache">La cache.</param>
 /// <param name="memoryStreamPool">Il pool degli stream in memoria.</param>
 public CaravanAssetsController(ILog log, ICache cache, IObjectPool<PooledMemoryStream> memoryStreamPool)
 {
     Raise.ArgumentNullException.IfIsNull(log, nameof(log));
     Raise.ArgumentNullException.IfIsNull(cache, nameof(cache));
     Raise.ArgumentNullException.IfIsNull(memoryStreamPool, nameof(memoryStreamPool));
     _log = log;
     _cache = cache;
     _memoryStreamPool = memoryStreamPool;
 }
コード例 #5
0
 public UdpUnicasterFactory(Identity identity, UdpClient udpClient, AcknowledgementCoordinator acknowledgementCoordinator, IObjectPool<byte[]> sendReceiveBufferPool, IAuditCounter resendsCounter, IAuditAggregator<int> resendsAggregator, IAuditAggregator<double> outboundMessageRateLimitAggregator, IAuditAggregator<double> sendQueueDepthAggregator) {
    this.identity = identity;
    this.udpClient = udpClient;
    this.acknowledgementCoordinator = acknowledgementCoordinator;
    this.sendReceiveBufferPool = sendReceiveBufferPool;
    this.resendsCounter = resendsCounter;
    this.resendsAggregator = resendsAggregator;
    this.outboundMessageRateLimitAggregator = outboundMessageRateLimitAggregator;
    this.sendQueueDepthAggregator = sendQueueDepthAggregator;
 }
コード例 #6
0
ファイル: CachingBin.cs プロジェクト: erdincay/db4o
		/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
		public CachingBin(IBin bin, ICache4 cache, int pageCount, int pageSize) : base(bin
			)
		{
			_onDiscardPage = new _IProcedure4_22(this);
			_producerFromDisk = new _IFunction4_138(this);
			_producerFromPool = new _IFunction4_147(this);
			_pageSize = pageSize;
			_pagePool = new SimpleObjectPool(NewPagePool(pageCount));
			_cache = cache;
			_fileLength = _bin.Length();
		}
コード例 #7
0
        /// <summary>
        ///   Inizializza il componente usato per la compressione.
        /// </summary>
        /// <param name="next">Un riferimento al prossimo componente della pipeline.</param>
        /// <param name="settings">Le impostazioni del componente.</param>
        /// <param name="log">Il log su cui scrivere eventuali messaggi.</param>
        /// <param name="memoryStreamPool">Il pool degli stream in memoria.</param>
        public HttpCompressionMiddleware(OwinMiddleware next, Settings settings, ICaravanLog log, IObjectPool<PooledMemoryStream> memoryStreamPool)
            : base(next)
        {
            // Preconditions
            Raise.ArgumentNullException.IfIsNull(settings, nameof(settings));
            Raise.ArgumentNullException.IfIsNull(log, nameof(log));
            Raise.ArgumentNullException.IfIsNull(memoryStreamPool, nameof(memoryStreamPool));

            _settings = settings;
            _log = log;
            _memoryStreamPool = memoryStreamPool;
        }
コード例 #8
0
		/// <summary>
		/// Creates the pool.
		/// </summary>
		/// <param name="factory">
		/// The owning <see cref="Spring.Objects.Factory.IObjectFactory"/>, in
		/// case one needs collaborators from it (normally one's own properties
		/// are sufficient).
		/// </param>
		/// <seealso cref="Spring.Objects.Factory.IObjectFactoryAware.ObjectFactory"/>
		protected override void CreatePool(IObjectFactory factory)
		{
			#region Instrumentation

			if(logger.IsDebugEnabled)
			{
				logger.Debug("Creating object pool.");
			}

			#endregion

			this.objectPool = CreateObjectPool();
		}
コード例 #9
0
        /// <summary>
        ///   Inizializza il componente usato per l'etichettatura delle request.
        /// </summary>
        /// <param name="next">Il componente successivo nella catena.</param>
        /// <param name="settings">Le impostazioni del componente.</param>
        /// <param name="log">Il log su cui scrivere eventuali messaggi.</param>
        /// <param name="memoryStreamPool">Il pool degli stream in memoria.</param>
        public HttpRequestIdentifierMiddleware(OwinMiddleware next, Settings settings, ILog log, IObjectPool<PooledMemoryStream> memoryStreamPool)
            : base(next)
        {
            // Preconditions
            Raise.ArgumentNullException.IfIsNull(settings, nameof(settings));
            Raise.ArgumentNullException.IfIsNull(settings.IgnoredPaths, nameof(settings.IgnoredPaths));
            Raise.ArgumentNullException.IfIsNull(log, nameof(log));
            Raise.ArgumentNullException.IfIsNull(memoryStreamPool, nameof(memoryStreamPool));

            _settings = settings;
            _log = log;
            _memoryStreamPool = memoryStreamPool;
        }
コード例 #10
0
		public ObjectManager()
		{
			this.m_data = new Dictionary<string, IPoolableFactory>();
			this.RegistClassType("Self.ObjectSet", new ObjectSetFactory());

			var p = new ObjectPool(this);
			this.m_idlePool = p;

			p = new ObjectPool(this, true);
			p.CreateAdminNode();
			this.m_busyPool = p;
			this.m_timer = new Timer(new TimerCallback(this.Cleanup));
			this.m_timer.Change(1000, 0);
		}
コード例 #11
0
        /// <summary>
        ///   Inizializza il componente usato per il logging.
        /// </summary>
        /// <param name="next">Un riferimento al prossimo componente della pipeline.</param>
        /// <param name="settings">Le impostazioni del componente.</param>
        /// <param name="log">Il log su cui scrivere eventuali messaggi.</param>
        /// <param name="perfMonitorFactory">L'oggetto usato per generare cronometri.</param>
        /// <param name="stringBuilderPool">Il pool di oggetti di tipo <see cref="StringBuilder"/>.</param>
        public HttpLoggingMiddleware(OwinMiddleware next, Settings settings, ICaravanLog log, IPerfMonitorFactory perfMonitorFactory, IObjectPool<PooledStringBuilder> stringBuilderPool)
            : base(next)
        {
            // Preconditions
            Raise.ArgumentNullException.IfIsNull(settings, nameof(settings));
            Raise.ArgumentNullException.IfIsNull(log, nameof(log));
            Raise.ArgumentNullException.IfIsNull(perfMonitorFactory, nameof(perfMonitorFactory));
            Raise.ArgumentNullException.IfIsNull(stringBuilderPool, nameof(stringBuilderPool));

            _settings = settings;
            _log = log;
            _perfMonitorFactory = perfMonitorFactory;
            _stringBuilderPool = stringBuilderPool;
        }
コード例 #12
0
 /// <summary>
 /// 设置对象池管理器。
 /// </summary>
 /// <param name="objectPoolManager">对象池管理器。</param>
 public void SetObjectPoolManager(IObjectPoolManager objectPoolManager)
 {
     m_AssetPool    = objectPoolManager.CreateMultiSpawnObjectPool <AssetObject>("Asset Pool");
     m_ResourcePool = objectPoolManager.CreateMultiSpawnObjectPool <ResourceObject>("Resource Pool");
 }
コード例 #13
0
 private static int CalcAmmount(IObjectPool objectPool)
 {
     return(Mathf.FloorToInt(objectPool.ActiveCount / objectPool.Ratio) - objectPool.Count);
 }
コード例 #14
0
ファイル: ObjectPoolComponent.cs プロジェクト: moyu3390/MM1
 /// <summary>
 /// 销毁对象池。
 /// </summary>
 /// <typeparam name="T">对象类型。</typeparam>
 /// <param name="objectPool">要销毁的对象池。</param>
 /// <returns>是否销毁对象池成功。</returns>
 public bool DestroyObjectPool <T>(IObjectPool <T> objectPool) where T : ObjectBase
 {
     return(m_ObjectPoolManager.DestroyObjectPool(objectPool));
 }
コード例 #15
0
 public AspectManager(IChannelManager channelManager, IObjectPool<IAspect> aspectPool)
 {
     _aspectPool = aspectPool;
     _channelManager = channelManager;
 }
コード例 #16
0
 public override void Init(IObjectPool <GameObject> pool)
 {
     base.Init(pool);
     _destroyableComponent            = GetComponent <IDestroyable>();
     _destroyableComponent.OnDestroy += ReturnOnDestroy;
 }
コード例 #17
0
			public _ICodeBlock_20(IObjectPool pool)
			{
				this.pool = pool;
			}
コード例 #18
0
 public MySimpleQueueAdapterCache(IQueueAdapterFactory factory, Logger logger)
 {
     _logger = logger;
     // 10 meg buffer pool.  10 1 meg blocks
     bufferPool = new FixedSizeObjectPool<FixedSizeBuffer>(10, pool => new FixedSizeBuffer(1 << 20, pool));
 }
コード例 #19
0
        /// <summary>
        /// 销毁对象池。
        /// </summary>
        /// <typeparam name="T">对象类型。</typeparam>
        /// <param name="objectPool">要销毁的对象池。</param>
        /// <returns>是否销毁对象池成功。</returns>
        public bool DestroyObjectPool <T>(IObjectPool <T> objectPool) where T : ObjectBase
        {
            Guard.Verify <ArgumentException>(objectPool == null, "Object type is invalid.");

            return(InnerDestroyObjectPool(Utility.Text.GetFullName <T>(objectPool.Name)));
        }
コード例 #20
0
ファイル: DecodedFrame.cs プロジェクト: forestrf/AlantaMedia
 public DecodedFrame(int height, int width, IObjectPool <FrameBlock> frameBlockPool)
     : base(height, width, frameBlockPool)
 {
     frame = new byte[height * width * VideoConstants.BytesPerPixel];
 }
 public SessionStateStaticObjectCollectionSerializationSurrogate(Type t, IObjectPool pool) : base(t, pool)
 {
 }
コード例 #22
0
 public CachedDataAdapter(string partitionKey, IObjectPool <FixedSizeBuffer> bufferPool)
     : base(bufferPool)
 {
     partitionStreamGuid = GetPartitionGuid(partitionKey);
 }
コード例 #23
0
 /// <summary>
 /// 设置对象池管理器
 /// </summary>
 public void SetObjectPoolManager()
 {
     m_AssetPool = GameEntry.Pool.CreateMultiSpawnObjectPool <AssetObject>("Texture Asset Pool", 60f, 64, 60f, 0);
 }
コード例 #24
0
ファイル: PacketWriter.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// Initializes a new instance of the <see cref="PacketWriter"/> class.
 /// </summary>
 internal PacketWriter(IObjectPool<PacketWriter> objectPool) : base(128)
 {
     _objectPool = objectPool;
 }
コード例 #25
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="t">The type for which it is a surrogate</param>
 public SerializationSurrogate(Type t, IObjectPool pool)
 {
     type       = t;
     ObjectPool = pool;
 }
コード例 #26
0
 public Helper(Latch latch, ISync sync, IObjectPool objectPool)
 {
     Init(latch, sync, objectPool);
 }
                /// <summary>
                /// 初始化加载资源代理的新实例。
                /// </summary>
                /// <param name="loadResourceAgentHelper">加载资源代理辅助器。</param>
                /// <param name="resourceHelper">资源辅助器。</param>
                /// <param name="assetPool">资源对象池。</param>
                /// <param name="resourcePool">资源对象池。</param>
                /// <param name="resourceLoader">加载资源器。</param>
                /// <param name="readOnlyPath">资源只读区路径。</param>
                /// <param name="readWritePath">资源读写区路径。</param>
                /// <param name="decryptResourceCallback">解密资源回调函数。</param>
                public LoadResourceAgent(ILoadResourceAgentHelper loadResourceAgentHelper, IResourceHelper resourceHelper, IObjectPool <AssetObject> assetPool, IObjectPool <ResourceObject> resourcePool, ResourceLoader resourceLoader, string readOnlyPath, string readWritePath, DecryptResourceCallback decryptResourceCallback)
                {
                    if (loadResourceAgentHelper == null)
                    {
                        throw new GameFrameworkException("Load resource agent helper is invalid.");
                    }

                    if (resourceHelper == null)
                    {
                        throw new GameFrameworkException("Resource helper is invalid.");
                    }

                    if (assetPool == null)
                    {
                        throw new GameFrameworkException("Asset pool is invalid.");
                    }

                    if (resourcePool == null)
                    {
                        throw new GameFrameworkException("Resource pool is invalid.");
                    }

                    if (resourceLoader == null)
                    {
                        throw new GameFrameworkException("Resource loader is invalid.");
                    }

                    if (decryptResourceCallback == null)
                    {
                        throw new GameFrameworkException("Decrypt resource callback is invalid.");
                    }

                    m_Helper                      = loadResourceAgentHelper;
                    m_ResourceHelper              = resourceHelper;
                    m_AssetPool                   = assetPool;
                    m_ResourcePool                = resourcePool;
                    m_ResourceLoader              = resourceLoader;
                    m_ReadOnlyPath                = readOnlyPath;
                    m_ReadWritePath               = readWritePath;
                    m_DecryptResourceCallback     = decryptResourceCallback;
                    m_LoadingDependencyAssetNames = new LinkedList <string>();
                    m_Task            = null;
                    m_WaitingType     = WaitingType.None;
                    m_LoadingAsset    = false;
                    m_LoadingResource = false;
                }
コード例 #28
0
ファイル: GameObjectPool.cs プロジェクト: 542767059/ABC
 /// <summary>
 /// 初始化GameObject对象池
 /// </summary>
 /// <param name="gameobjectAsset">对象资源</param>
 /// <param name="name">对象名称</param>
 /// <param name="autoReleaseInterval">对象池自动释放间隔</param>
 /// <param name="capacity">对象池容量</param>
 /// <param name="expireTime">对象过期时间</param>
 /// <param name="priority">对象池优先级</param>
 public GameObjectPool(GameObject gameobjectAsset, string name, float autoReleaseInterval, int capacity, float expireTime, int priority)
 {
     m_GameobjectAsset        = gameobjectAsset;
     m_InstanceGameObjectPool = GameEntry.Pool.CreateSingleSpawnObjectPool <InstanceGameObject>(TextUtil.Format("GameObject Instance Pool ({0})", name), autoReleaseInterval, capacity, expireTime, priority);
 }
コード例 #29
0
 /// <summary>
 /// Builds a new <see cref="PooledObjectHolder"/>
 /// trying to borrow an object form it
 /// </summary>
 /// <param name="pool"></param>
 private PooledObjectHolder(IObjectPool pool)
 {
     this.pool = pool;
     this.pooled = pool.BorrowObject();
 }
コード例 #30
0
 public override void ReturnConnection(IObjectPool <DbConnection> pool, Object <DbConnection> conn, Exception ex) => _ado.ReturnConnection(pool, conn, ex);
コード例 #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinqCompiler" /> class.
 /// </summary>
 /// <param name="objectPool">The object pool.</param>
 public LinqCompiler(IObjectPool<DynamicCodeCompiler> objectPool)
 {
     _objectPool = objectPool;
 }
コード例 #32
0
 public void OnSpawned(IObjectPool <Bullet> pool)
 {
     _pool = pool;
     StartCoroutine(SelfDestructAfterDuration());
 }
コード例 #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinqCompiler" /> class.
 /// </summary>
 /// <param name="objectPool">The object pool.</param>
 public LinqCompiler(IObjectPool <DynamicCodeCompiler> objectPool)
 {
     _objectPool = objectPool;
 }
コード例 #34
0
 public void OnDespawned()
 {
     _pool = null;
 }
コード例 #35
0
 public InitContext(IObjectPool objectPool)
 {
     ObjectPool = objectPool;
 }
コード例 #36
0
 public CachedDataAdapter(string partitionKey, IObjectPool <FixedSizeBuffer> bufferPool, TimePurgePredicate timePurge)
     : base(bufferPool, timePurge)
 {
     partitionStreamGuid = GetPartitionGuid(partitionKey);
 }
コード例 #37
0
 internal PooledObject(T value, IObjectPool <T> pool)
 {
     m_ToReturn = value;
     m_Pool     = pool;
 }
コード例 #38
0
 public CheckableObjectPool(IObjectPool <T> origin) : base(origin)
 {
 }
コード例 #39
0
ファイル: TestMocks.cs プロジェクト: zengpengkindle/orleans
 public EventHubQueueCacheForTesting(IObjectPool <FixedSizeBuffer> bufferPool, IEventHubDataAdapter dataAdapter, IEvictionStrategy evictionStrategy, IStreamQueueCheckpointer <string> checkpointer,
                                     ILogger logger)
     : base("test", EventHubAdapterReceiver.MaxMessagesPerRead, bufferPool, dataAdapter, evictionStrategy, checkpointer, logger, null, null)
 {
 }
コード例 #40
0
 public MeshCanvasBuilder(IObjectPool objectPool)
 {
     _objectPool = objectPool;
     _clipper    = objectPool.NewObject <Clipper>();
     _offset     = objectPool.NewObject <ClipperOffset>();
 }
コード例 #41
0
 void Start()
 {
     factory    = new FactorySpawn(data);
     objectPool = new ObjectPool(factory, poolPartycleParent);
     spawner    = new SpawnerMultiColor(objectPool, data, movePartycleParent);
 }
コード例 #42
0
ファイル: SimplePoolTest.cs プロジェクト: Binodesk/spring-net
 public void Init(Latch latch, ISync sync, IObjectPool objectPool)
 {
     this.sync = sync;
     this.latch = latch;
     this.objectPool = objectPool;
 }
コード例 #43
0
 public void Init(Latch latch, ISync sync, IObjectPool objectPool)
 {
     this.sync       = sync;
     this.latch      = latch;
     this.objectPool = objectPool;
 }
コード例 #44
0
 public Queuer (IObjectPool pool, IRunnable runnable)
 {
     this.pool = pool;
     this.runnable = runnable;
     this.sync = new Latch();
 }
コード例 #45
0
ファイル: SimplePoolTest.cs プロジェクト: Binodesk/spring-net
 public Helper(Latch latch, ISync sync, IObjectPool objectPool)
 {
     Init(latch, sync, objectPool);
 }
コード例 #46
0
 public ObjectPoolTests()
 {
     _items = new ObjectPool<TestData>(() => new TestData(), td => td.Data = "Reset at " + DateTime.Now.ToShortDateString());
 }
コード例 #47
0
 /// <summary>
 /// Creates a new <see cref="PooledObjectHolder"/> for the 
 /// given pool.
 /// </summary>
 public static PooledObjectHolder UseFrom(IObjectPool pool)
 {
     return new PooledObjectHolder(pool);
 }
コード例 #48
0
                public AssetObject(string name, object target, object[] dependencyAssets, object resource, IObjectPool <AssetObject> assetPool, IObjectPool <ResourceObject> resourcePool, IResourceHelper resourceHelper, Dictionary <object, int> dependencyCount)
                    : base(name, target)
                {
                    if (dependencyAssets == null)
                    {
                        throw new GameFrameworkException("Dependency assets is invalid.");
                    }

                    if (resource == null)
                    {
                        throw new GameFrameworkException("Resource is invalid.");
                    }

                    if (assetPool == null)
                    {
                        throw new GameFrameworkException("Asset pool is invalid.");
                    }

                    if (resourcePool == null)
                    {
                        throw new GameFrameworkException("Resource pool is invalid.");
                    }

                    if (resourceHelper == null)
                    {
                        throw new GameFrameworkException("Resource helper is invalid.");
                    }

                    if (dependencyCount == null)
                    {
                        throw new GameFrameworkException("Dependency count is invalid.");
                    }

                    m_DependencyAssets = dependencyAssets;
                    m_Resource         = resource;
                    m_AssetPool        = assetPool;
                    m_ResourcePool     = resourcePool;
                    m_ResourceHelper   = resourceHelper;
                    m_DependencyCount  = dependencyCount;

                    foreach (object dependencyAsset in m_DependencyAssets)
                    {
                        int referenceCount = 0;
                        if (m_DependencyCount.TryGetValue(dependencyAsset, out referenceCount))
                        {
                            m_DependencyCount[dependencyAsset] = referenceCount + 1;
                        }
                        else
                        {
                            m_DependencyCount.Add(dependencyAsset, 1);
                        }
                    }
                }
コード例 #49
0
 public static ISync Queue (IObjectPool pool, IRunnable runnable)
 {
     Queuer queuer = new Queuer(pool, runnable);
     Thread thread = new Thread(new ThreadStart(queuer.Queue));
     thread.Start();
     return queuer.Sync;
 }
コード例 #50
0
 /// <summary>
 ///   Adapts given object pool.
 /// </summary>
 /// <param name="objectPool">The object pool that needs to be adapted.</param>
 /// <exception cref="ArgumentNullException"><paramref name="objectPool"/> is null.</exception>
 public ObjectPoolAdapterForPooledObject(IObjectPool <T> objectPool)
 {
     _adaptedObjectPool = objectPool ?? throw new ArgumentNullException(nameof(objectPool));
 }
コード例 #51
0
 private static float NextRatio(IObjectPool objectPool)
 {
     return (float) objectPool.ActiveCount/(objectPool.Count + 1);
 }
コード例 #52
0
 /// <summary>
 ///   Adapts an <see cref="IObjectPool{T}"/> implementation to
 ///   <see cref="Microsoft.Extensions.ObjectPool.ObjectPool{T}"/> abstract class.
 /// </summary>
 /// <typeparam name="T">The type of the resource.</typeparam>
 /// <param name="objectPool">The object pool that needs to be adapted.</param>
 /// <returns>An adapter for given object pool.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="objectPool"/> is null.</exception>
 /// <remarks>
 ///   This adapter should be used for types that do _not_ extend <see cref="PooledObject"/> class.
 /// </remarks>
 public static Microsoft.Extensions.ObjectPool.ObjectPool <T> Create <T>(IObjectPool <PooledObjectWrapper <T> > objectPool)
     where T : class => new ObjectPoolAdapter <T>(objectPool);
コード例 #53
0
 public override void ReleaseResources(IObjectPool objectPool)
 {
     objectPool.ReleaseObject(Weapon);
     objectPool.ReleaseObject(MouseHoverColorTransition);
     base.ReleaseResources(objectPool);
 }
コード例 #54
0
 /// <summary>
 ///   Adapts an <see cref="IObjectPool{T}"/> implementation to
 ///   <see cref="Microsoft.Extensions.ObjectPool.ObjectPool{T}"/> abstract class.
 /// </summary>
 /// <typeparam name="T">The type of the resource.</typeparam>
 /// <param name="objectPool">The object pool that needs to be adapted.</param>
 /// <returns>An adapter for given object pool.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="objectPool"/> is null.</exception>
 /// <remarks>
 ///   This adapter should be used for types that extend <see cref="PooledObject"/> class.
 /// </remarks>
 public static Microsoft.Extensions.ObjectPool.ObjectPool <T> CreateForPooledObject <T>(IObjectPool <T> objectPool)
     where T : PooledObject => new ObjectPoolAdapterForPooledObject <T>(objectPool);