예제 #1
0
파일: List.cpp 프로젝트: brunolauze/pegasus
void ListRep::clear()
{
    PEGASUS_DEBUG_ASSERT(_magic);

    if (_destructor)
    {
        // Reset _front, _back, and _size in case the destructor calls
        // a method of List.

        Linkable* front = _front;

        _front = 0;
        _back = 0;
        _size = 0;

        for (Linkable* p = front; p; )
        {
            PEGASUS_DEBUG_ASSERT(p->magic);
            Linkable* next = p->next;
            p->list = 0;
            _destructor(p);
            p = next;
        }
    }
}
예제 #2
0
	//! 참조계수 감소
	int release( void ){
		//! 메모리장벽으로 release 이전의 operation 이 다른 thread 에서 관측되게 한다.
		int val = _counter.fetch_sub(1 
			, std::memory_order::memory_order_release ) - 1;
		if ( val == 0 ) {			
			Object* obj = static_cast<Object*>(this);
			if( _destructor ){
				_destructor( obj );
			} else {
				delete obj;
			}
		}
		return val;
	}