示例#1
0
void ZTBowl::Changed(ZTSoup::EChanged iChanged)
	{
	set<uint64> removedIDs;
	this->GetRemoved(removedIDs);

	if (!removedIDs.empty())
		{
		for (vector<ZRef<ZTCrouton> >::iterator i = fTCroutons.begin();
			i != fTCroutons.end(); /*no inc*/)
			{
			if (sContains(removedIDs, (*i)->GetID()))
				{
				ZRef<ZTCrouton> theTCrouton = *i;
				if (ZLOG(s, eDebug, "ZTBowl"))
					{
					s << "Changed, removing TCrouton, ID: "
						<< sStringf("%llX", theTCrouton->GetID())
						<< ", Address: " << sStringf("%p", theTCrouton.Get());
					}

				(*i).StaticCast<ZTCrouton_Bowl>()->fTBowl.Clear();
				i = fTCroutons.erase(i);
				}
			else
				{
				++i;
				}
			}
		}

	ZRef<ZTBowl> selfRef = this;
	set<uint64> addedIDs;
	this->GetAdded(addedIDs);
	for (set<uint64>::const_iterator i = addedIDs.begin(); i != addedIDs.end(); ++i)
		{
		ZRef<ZTCrouton_Bowl> newCrouton = this->MakeCrouton();
		newCrouton->fTBowl = selfRef;
		fTCroutons.push_back(newCrouton);

		if (ZLOG(s, eDebug, "ZTBowl"))
			{
			s << "Changed, added TCrouton, ID: " << sStringf("%llX", *i)
				<< ", Address: " << sStringf("%p", newCrouton.Get());
			}

		this->GetTSoup()->Register(newCrouton, *i);
		}
	}
示例#2
0
void ZTSoup::Register(ZRef<ZTCrouton> iTCrouton, uint64 iID)
	{
	ZMutexLocker locker_CallUpdate(fMutex_CallUpdate);
	ZMutexLocker locker_Structure(fMutex_Structure);

	PCrouton* thePCrouton = this->pGetPCrouton(iID);

	if (ZLOG(s, eDebug + 1, "ZTSoup"))
		{
		s.Writef("Registering TCrouton, ID: %llX", iID);
		if (!thePCrouton->fWatcherKnown)
			s << ", not known to watcher";
		}

	ZTCrouton* theTCrouton = iTCrouton.Get();
	iTCrouton->fPCrouton = thePCrouton;
	sInsertBackMust(thePCrouton->fTCroutons_Using, theTCrouton);

	sQInsertBack(fPCroutons_Update, thePCrouton);
	sQErase(fPCroutons_Pending, thePCrouton);
	this->pTriggerUpdate();

	if (thePCrouton->fHasValue)
		{
		locker_Structure.Release();
		this->Loaded(iTCrouton, eLoaded_Registration);
		}
	}
示例#3
0
void Visitor_DoMakeWalker::Visit(const ZRef<ZVisitee>& iRep)
	{
	if (ZLOGPF(w, eDebug))
		w << "Unimplemented for visitee: " << typeid(*iRep.Get()).name();

	ZUnimplemented();
	}
示例#4
0
ZRef<CGDataProviderRef> ZStream_CGData::sProvider(ZRef<ZStreamerR> iStreamer)
{
    if (iStreamer)
    {
        iStreamer->Retain();
        return sAdopt& ::CGDataProviderCreate(iStreamer.Get(), &spCallbacks_R);
    }
    return null;
}
示例#5
0
ZRef<CGDataConsumerRef> ZStream_CGData::sConsumer(ZRef<ZStreamerW> iStreamer)
{
    if (iStreamer)
    {
        iStreamer->Retain();
        return sAdopt& ::CGDataConsumerCreate(iStreamer.Get(), &spCallbacks_W);
    }
    return null;
}
示例#6
0
ZRef<CGDataProviderRef> ZStream_CGData::sProvider(ZRef<ZStreamerRPos> iStreamer)
{
    if (iStreamer)
    {
        iStreamer->Retain();
        return sAdopt& ::CGDataProviderCreateSequential(iStreamer.Get(), &spCallbacksSequential_RPos);
    }
    return null;
}
示例#7
0
void ZTSoup::Register(ZRef<ZTSieve> iTSieve, const ZTBQuery& iTBQuery, bool iPrefetch)
	{
	ZMutexLocker locker_CallUpdate(fMutex_CallUpdate);
	ZMutexLocker locker_Structure(fMutex_Structure);

	iTSieve->fJustRegistered = true;

	PSieve* thePSieve;
	map<ZTBQuery, PSieve>::iterator position = fTBQuery_To_PSieve.lower_bound(iTBQuery);
	if (position != fTBQuery_To_PSieve.end() && position->first == iTBQuery)
		{
		thePSieve = &position->second;
		if (iPrefetch && !thePSieve->fPrefetch)
			{
			thePSieve->fPrefetch = true;
			sQInsertBack(fPSieves_Update, thePSieve);
			}
		}
	else
		{
		thePSieve = &fTBQuery_To_PSieve.
			insert(position, pair<ZTBQuery, PSieve>(iTBQuery, PSieve()))->second;

		thePSieve->fTSoup = this;
		thePSieve->fTBQuery = iTBQuery;
		thePSieve->fWatcherKnown = false;
		thePSieve->fPrefetch = iPrefetch;
		thePSieve->fHasResults = false;
		thePSieve->fHasDiffs = false;

		sInsertBackMust(fPSieves_Update, thePSieve);

		this->pTriggerUpdate();
		}

	if (ZLOG(s, eDebug + 1, "ZTSoup"))
		{
		s.Writef("Registering against sieve, ID: %p", thePSieve);
		if (!thePSieve->fWatcherKnown)
			s << ", not known to watcher";
		}

	ZTSieve* theTSieve = iTSieve.Get();
	theTSieve->fPSieve = thePSieve;
	sInsertBackMust(thePSieve->fTSieves_Using, theTSieve);

	if (thePSieve->fHasResults)
		{
		locker_Structure.Release();
		this->Loaded(iTSieve, eLoaded_Registration);
		}
	}
示例#8
0
ZRef<Roster::Entry> Roster::MakeEntry(const ZRef<Callable_Void>& iCallable_Broadcast,
	const ZRef<Callable_Void>& iCallable_Gone)
	{
	ZRef<Entry> theEntry = new Entry(this, iCallable_Broadcast, iCallable_Gone);

	{
	ZAcqMtx acq(fMtx);
	sInsertMust(fEntries, theEntry.Get());
	fCnd.Broadcast();
	}

	sCall(fCallable_Change);

	return theEntry;
	}