File diff r18781:e1de9a06f7cd → r18782:6453522c2154
src/core/pool_type.hpp
Show inline comments
 
@@ -98,7 +98,7 @@ struct Pool : PoolBase {
 
	 * @return pointer to Titem
 
	 * @pre index < this->first_unused
 
	 */
 
	FORCEINLINE Titem *Get(size_t index)
 
	inline Titem *Get(size_t index)
 
	{
 
		assert(index < this->first_unused);
 
		return this->data[index];
 
@@ -109,7 +109,7 @@ struct Pool : PoolBase {
 
	 * @param index index to examine
 
	 * @return true if PoolItem::Get(index) will return non-NULL pointer
 
	 */
 
	FORCEINLINE bool IsValidID(size_t index)
 
	inline bool IsValidID(size_t index)
 
	{
 
		return index < this->first_unused && this->Get(index) != NULL;
 
	}
 
@@ -119,7 +119,7 @@ struct Pool : PoolBase {
 
	 * @param n number of items we want to allocate
 
	 * @return true if 'n' items can be allocated
 
	 */
 
	FORCEINLINE bool CanAllocate(size_t n = 1)
 
	inline bool CanAllocate(size_t n = 1)
 
	{
 
		bool ret = this->items <= Tmax_size - n;
 
#ifdef OTTD_ASSERT
 
@@ -142,7 +142,7 @@ struct Pool : PoolBase {
 
		 * @return pointer to allocated memory
 
		 * @note can never fail (return NULL), use CanAllocate() to check first!
 
		 */
 
		FORCEINLINE void *operator new(size_t size)
 
		inline void *operator new(size_t size)
 
		{
 
			return Tpool->GetNew(size);
 
		}
 
@@ -152,7 +152,7 @@ struct Pool : PoolBase {
 
		 * @param p memory to free
 
		 * @note the item has to be allocated in the pool!
 
		 */
 
		FORCEINLINE void operator delete(void *p)
 
		inline void operator delete(void *p)
 
		{
 
			Titem *pn = (Titem *)p;
 
			assert(pn == Tpool->Get(pn->index));
 
@@ -167,7 +167,7 @@ struct Pool : PoolBase {
 
		 * @note can never fail (return NULL), use CanAllocate() to check first!
 
		 * @pre index has to be unused! Else it will crash
 
		 */
 
		FORCEINLINE void *operator new(size_t size, size_t index)
 
		inline void *operator new(size_t size, size_t index)
 
		{
 
			return Tpool->GetNew(size, index);
 
		}
 
@@ -180,7 +180,7 @@ struct Pool : PoolBase {
 
		 * @note use of this is strongly discouraged
 
		 * @pre the memory must not be allocated in the Pool!
 
		 */
 
		FORCEINLINE void *operator new(size_t size, void *ptr)
 
		inline void *operator new(size_t size, void *ptr)
 
		{
 
			for (size_t i = 0; i < Tpool->first_unused; i++) {
 
				/* Don't allow creating new objects over existing.
 
@@ -202,7 +202,7 @@ struct Pool : PoolBase {
 
		 * @param n number of items we want to allocate
 
		 * @return true if 'n' items can be allocated
 
		 */
 
		static FORCEINLINE bool CanAllocateItem(size_t n = 1)
 
		static inline bool CanAllocateItem(size_t n = 1)
 
		{
 
			return Tpool->CanAllocate(n);
 
		}
 
@@ -211,7 +211,7 @@ struct Pool : PoolBase {
 
		 * Returns current state of pool cleaning - yes or no
 
		 * @return true iff we are cleaning the pool now
 
		 */
 
		static FORCEINLINE bool CleaningPool()
 
		static inline bool CleaningPool()
 
		{
 
			return Tpool->cleaning;
 
		}
 
@@ -221,7 +221,7 @@ struct Pool : PoolBase {
 
		 * @param index index to examine
 
		 * @return true if PoolItem::Get(index) will return non-NULL pointer
 
		 */
 
		static FORCEINLINE bool IsValidID(size_t index)
 
		static inline bool IsValidID(size_t index)
 
		{
 
			return Tpool->IsValidID(index);
 
		}
 
@@ -232,7 +232,7 @@ struct Pool : PoolBase {
 
		 * @return pointer to Titem
 
		 * @pre index < this->first_unused
 
		 */
 
		static FORCEINLINE Titem *Get(size_t index)
 
		static inline Titem *Get(size_t index)
 
		{
 
			return Tpool->Get(index);
 
		}
 
@@ -243,7 +243,7 @@ struct Pool : PoolBase {
 
		 * @return pointer to Titem
 
		 * @note returns NULL for invalid index
 
		 */
 
		static FORCEINLINE Titem *GetIfValid(size_t index)
 
		static inline Titem *GetIfValid(size_t index)
 
		{
 
			return index < Tpool->first_unused ? Tpool->Get(index) : NULL;
 
		}
 
@@ -253,7 +253,7 @@ struct Pool : PoolBase {
 
		 * all pool items.
 
		 * @return first unused index
 
		 */
 
		static FORCEINLINE size_t GetPoolSize()
 
		static inline size_t GetPoolSize()
 
		{
 
			return Tpool->first_unused;
 
		}
 
@@ -262,7 +262,7 @@ struct Pool : PoolBase {
 
		 * Returns number of valid items in the pool
 
		 * @return number of valid items in the pool
 
		 */
 
		static FORCEINLINE size_t GetNumItems()
 
		static inline size_t GetNumItems()
 
		{
 
			return Tpool->items;
 
		}
 
@@ -274,7 +274,7 @@ struct Pool : PoolBase {
 
		 * @note when this function is called, PoolItem::Get(index) == NULL.
 
		 * @note it's called only when !CleaningPool()
 
		 */
 
		static FORCEINLINE void PostDestructor(size_t index) { }
 
		static inline void PostDestructor(size_t index) { }
 
	};
 

	
 
private: