예제 #1
0
void ZRefCountedWithFinalization::sDecRefCount(ZRefCountedWithFinalization* iObject)
	{
	if (!iObject)
		return;

	#if ZCONFIG_Thread_Preemptive

		for (;;)
			{
			int oldRefCount = ZAtomic_Get(&iObject->fRefCount);
			if (oldRefCount == 1)
				{
				iObject->Finalize();
				break;
				}
			else
				{
				if (ZAtomic_CompareAndSwap(&iObject->fRefCount, oldRefCount, oldRefCount - 1))
					break;
				// We'll only have to loop if we were preempted between the call to
				// ZAtomic_Get and the call to ZAtomic_CompareAndSwap, so we'll very
				// likely succeed next time round the loop.
				}
			}
	#else

		if (ZThreadSafe_DecAndTest(iObject->fRefCount))
			{
			ZThreadSafe_Set(iObject->fRefCount, 1);
			iObject->Finalize();
			}

	#endif
	}
예제 #2
0
ZDragClip_Win_Enum::ZDragClip_Win_Enum(ZDragClip_Win_DataObject* iDataObject, size_t iInitialIndex)
	{
	fTuple = *iDataObject->GetTuple();
	fCurrentIter = fTuple.begin();
	while (iInitialIndex && fCurrentIter != fTuple.end())
		{
		--iInitialIndex;
		++fCurrentIter;
		}
	ZThreadSafe_Set(fRefCount, 0);
	}
예제 #3
0
ZDragClip_Win_DataObject::ZDragClip_Win_DataObject(const ZTuple& iTuple)
:	fTuple(iTuple)
	{
	ZThreadSafe_Set(fRefCount, 0);
	}
예제 #4
0
ZDragClip_Win_DropSource::ZDragClip_Win_DropSource()
	{
	ZThreadSafe_Set(fRefCount, 0);
	}
예제 #5
0
ZDragClip_Win_Enum::ZDragClip_Win_Enum(const ZTuple& iTuple, ZTuple::const_iterator iCurrentIter)
:	fTuple(iTuple),
	fCurrentIter(iCurrentIter)
	{
	ZThreadSafe_Set(fRefCount, 0);
	}