Example #1
0
void writeContentOnBaseChannel(CircularBuffer* buf, BaseChannel* bc)
{
	chMtxLock(&(buf->mutex));
	while (!bufferIsEmpty(buf))
	{
		chprintf(bc, "%c", bufferRemove(buf));
	}
	chMtxUnlock();
}
Example #2
0
 void Input::removeUnused(){
   for (std::map<unsigned int, std::map<unsigned int, unsigned int> >::iterator it = pageCounter.begin(); it != pageCounter.end(); it++){
     for (std::map<unsigned int, unsigned int>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++){
       it2->second--;
     }
     bool change = true;
     while (change){
       change = false;
       for (std::map<unsigned int, unsigned int>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++){
         if (!it2->second){
           bufferRemove(it->first, it2->first);
           pageCounter[it->first].erase(it2->first);
           for (int i = 0; i < 8192; i += 8){
             unsigned int thisKeyNum = ntohl(((((long long int *)(metaPages[it->first].mapped + i))[0]) >> 32) & 0xFFFFFFFF);
             if (thisKeyNum == it2->first){
               (((long long int *)(metaPages[it->first].mapped + i))[0]) = 0;
             }
           }
           change = true;
           break;
         }
       }
     }
   }