Exemplo n.º 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;
 }
Exemplo n.º 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();
 }
Exemplo n.º 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;
 }
 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;
 }
Exemplo n.º 6
0
		/// <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();
		}
Exemplo n.º 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;
        }
		/// <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();
		}
        /// <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;
        }
Exemplo n.º 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);
		}
Exemplo n.º 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;
        }
 /// <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");
 }
Exemplo n.º 13
0
 private static int CalcAmmount(IObjectPool objectPool)
 {
     return(Mathf.FloorToInt(objectPool.ActiveCount / objectPool.Ratio) - objectPool.Count);
 }
Exemplo n.º 14
0
 /// <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));
 }
Exemplo n.º 15
0
 public AspectManager(IChannelManager channelManager, IObjectPool<IAspect> aspectPool)
 {
     _aspectPool = aspectPool;
     _channelManager = channelManager;
 }
Exemplo n.º 16
0
 public override void Init(IObjectPool <GameObject> pool)
 {
     base.Init(pool);
     _destroyableComponent            = GetComponent <IDestroyable>();
     _destroyableComponent.OnDestroy += ReturnOnDestroy;
 }
Exemplo n.º 17
0
			public _ICodeBlock_20(IObjectPool pool)
			{
				this.pool = pool;
			}
 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));
 }
Exemplo n.º 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)));
        }
Exemplo n.º 20
0
 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)
 {
 }
Exemplo n.º 22
0
 public CachedDataAdapter(string partitionKey, IObjectPool <FixedSizeBuffer> bufferPool)
     : base(bufferPool)
 {
     partitionStreamGuid = GetPartitionGuid(partitionKey);
 }
Exemplo n.º 23
0
 /// <summary>
 /// 设置对象池管理器
 /// </summary>
 public void SetObjectPoolManager()
 {
     m_AssetPool = GameEntry.Pool.CreateMultiSpawnObjectPool <AssetObject>("Texture Asset Pool", 60f, 64, 60f, 0);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PacketWriter"/> class.
 /// </summary>
 internal PacketWriter(IObjectPool<PacketWriter> objectPool) : base(128)
 {
     _objectPool = objectPool;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
                }
Exemplo n.º 28
0
 /// <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);
 }
Exemplo n.º 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();
 }
Exemplo n.º 30
0
 public override void ReturnConnection(IObjectPool <DbConnection> pool, Object <DbConnection> conn, Exception ex) => _ado.ReturnConnection(pool, conn, ex);
Exemplo n.º 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;
 }
Exemplo n.º 32
0
 public void OnSpawned(IObjectPool <Bullet> pool)
 {
     _pool = pool;
     StartCoroutine(SelfDestructAfterDuration());
 }
Exemplo n.º 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;
 }
Exemplo n.º 34
0
 public void OnDespawned()
 {
     _pool = null;
 }
Exemplo n.º 35
0
 public InitContext(IObjectPool objectPool)
 {
     ObjectPool = objectPool;
 }
Exemplo n.º 36
0
 public CachedDataAdapter(string partitionKey, IObjectPool <FixedSizeBuffer> bufferPool, TimePurgePredicate timePurge)
     : base(bufferPool, timePurge)
 {
     partitionStreamGuid = GetPartitionGuid(partitionKey);
 }
 internal PooledObject(T value, IObjectPool <T> pool)
 {
     m_ToReturn = value;
     m_Pool     = pool;
 }
Exemplo n.º 38
0
 public CheckableObjectPool(IObjectPool <T> origin) : base(origin)
 {
 }
Exemplo n.º 39
0
 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)
 {
 }
Exemplo n.º 40
0
 public MeshCanvasBuilder(IObjectPool objectPool)
 {
     _objectPool = objectPool;
     _clipper    = objectPool.NewObject <Clipper>();
     _offset     = objectPool.NewObject <ClipperOffset>();
 }
Exemplo n.º 41
0
 void Start()
 {
     factory    = new FactorySpawn(data);
     objectPool = new ObjectPool(factory, poolPartycleParent);
     spawner    = new SpawnerMultiColor(objectPool, data, movePartycleParent);
 }
Exemplo n.º 42
0
 public void Init(Latch latch, ISync sync, IObjectPool objectPool)
 {
     this.sync = sync;
     this.latch = latch;
     this.objectPool = objectPool;
 }
Exemplo n.º 43
0
 public void Init(Latch latch, ISync sync, IObjectPool objectPool)
 {
     this.sync       = sync;
     this.latch      = latch;
     this.objectPool = objectPool;
 }
Exemplo n.º 44
0
 public Queuer (IObjectPool pool, IRunnable runnable)
 {
     this.pool = pool;
     this.runnable = runnable;
     this.sync = new Latch();
 }
Exemplo n.º 45
0
 public Helper(Latch latch, ISync sync, IObjectPool objectPool)
 {
     Init(latch, sync, objectPool);
 }
Exemplo n.º 46
0
 public ObjectPoolTests()
 {
     _items = new ObjectPool<TestData>(() => new TestData(), td => td.Data = "Reset at " + DateTime.Now.ToShortDateString());
 }
Exemplo n.º 47
0
 /// <summary>
 /// Creates a new <see cref="PooledObjectHolder"/> for the 
 /// given pool.
 /// </summary>
 public static PooledObjectHolder UseFrom(IObjectPool pool)
 {
     return new PooledObjectHolder(pool);
 }
Exemplo n.º 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);
                        }
                    }
                }
Exemplo n.º 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;
 }
Exemplo n.º 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));
 }
 private static float NextRatio(IObjectPool objectPool)
 {
     return (float) objectPool.ActiveCount/(objectPool.Count + 1);
 }
Exemplo n.º 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);
Exemplo n.º 53
0
 public override void ReleaseResources(IObjectPool objectPool)
 {
     objectPool.ReleaseObject(Weapon);
     objectPool.ReleaseObject(MouseHoverColorTransition);
     base.ReleaseResources(objectPool);
 }
Exemplo n.º 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);