本文整理汇总了C++中PolyObject::AsBytePtr方法的典型用法代码示例。如果您正苦于以下问题:C++ PolyObject::AsBytePtr方法的具体用法?C++ PolyObject::AsBytePtr怎么用?C++ PolyObject::AsBytePtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PolyObject
的用法示例。
在下文中一共展示了PolyObject::AsBytePtr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hashAndSortAllTask
void SortVector::hashAndSortAllTask(GCTaskId*, void *a, void *b)
{
SortVector *s = (SortVector *)a;
// Hash the contents of the base object then sort them.
for (unsigned i = 0; i < 256; i++)
{
// Clear the entries in the hash table but not the sharing count.
s->processObjects[i].objList = ENDOFLIST;
s->processObjects[i].objCount = 0;
}
PolyObject *h = s->baseObject.objList;
POLYUNSIGNED bytes = OBJ_OBJECT_LENGTH(s->lengthWord)*sizeof(PolyWord);
while (h != ENDOFLIST)
{
PolyObject *next = h->GetForwardingPtr();
unsigned char hash = 0;
for (POLYUNSIGNED j = 0; j < bytes; j++)
hash += h->AsBytePtr()[j];
h->SetForwardingPtr(s->processObjects[hash].objList);
s->processObjects[hash].objList = h;
s->processObjects[hash].objCount++;
h = next;
}
s->SortData();
}
示例2: real_result
Handle real_result(TaskData *mdTaskData, double x)
{
union db argx;
argx.dble = x;
PolyObject *v = alloc(mdTaskData, DBLE/sizeof(PolyWord), F_BYTE_OBJ);
/* Copy as words in case the alignment is wrong. */
for(unsigned i = 0; i < DBLE; i++)
{
v->AsBytePtr()[i] = argx.bytes[i];
}
return mdTaskData->saveVec.push(v);
}
示例3: wordDataTask
// Process one level of the word data.
// N.B. The length words are updated without any locking. This is safe
// because all length words are initially chain entries and a chain entry
// can be replaced by another chain entry, a forwarding pointer or a normal
// length word. Forwarding pointers and normal length words are only ever
// set once. There is a small chance that we could lose some sharing as a
// result of a race condition if a thread defers an object because it
// contains a pointer with a chain entry and later sees an otherwise
// equal object where another thread has replaced the chain with a
// normal address, adds it to the list for immediate processing and
// so never compares the two.
void SortVector::wordDataTask(GCTaskId*, void *a, void *)
{
SortVector *s = (SortVector*)a;
// Partition the objects between those that have pointers to objects that are
// still to be processed and those that have been processed.
if (s->baseObject.objList == ENDOFLIST)
return;
PolyObject *h = s->baseObject.objList;
s->baseObject.objList = ENDOFLIST;
s->baseObject.objCount = 0;
POLYUNSIGNED words = OBJ_OBJECT_LENGTH(s->lengthWord);
s->carryOver = 0;
for (unsigned i = 0; i < 256; i++)
{
// Clear the entries in the hash table but not the sharing count.
s->processObjects[i].objList = ENDOFLIST;
s->processObjects[i].objCount = 0;
}
while (h != ENDOFLIST)
{
PolyObject *next = h->GetForwardingPtr();
bool deferred = false;
for (POLYUNSIGNED i = 0; i < words; i++)
{
PolyWord w = h->Get(i);
if (w.IsDataPtr())
{
PolyObject *p = w.AsObjPtr();
objectState state = getObjectState(p);
if (state == FORWARDED)
{
// Update the addresses of objects that have been merged
h->Set(i, p->GetForwardingPtr());
s->carryOver++;
break;
}
else if (state == CHAINED)
{
// If it is still to be shared leave it
deferred = true;
break; // from the loop
}
}
}
if (deferred)
{
// We can't do it yet: add it back to the list
h->SetForwardingPtr(s->baseObject.objList);
s->baseObject.objList = h;
s->baseObject.objCount++;
}
else
{
// Add it to the hash table.
unsigned char hash = 0;
for (POLYUNSIGNED i = 0; i < words*sizeof(PolyWord); i++)
hash += h->AsBytePtr()[i];
h->SetForwardingPtr(s->processObjects[hash].objList);
s->processObjects[hash].objList = h;
s->processObjects[hash].objCount++;
}
h = next;
}
s->SortData();
}