Пример #1
0
void 
EventSender<EvType>::removeListener(TListener* lisnr)
{
    if (_isBusySending)
    {
        if (! removeFrom(_registrationQueue, lisnr))
        {
            assert(std::find(_removalQueue.begin(), 
                   _removalQueue.end(), lisnr) == _removalQueue.end());
            _removalQueue.push_back(lisnr);

           theseLogs.logNdev(1,"Putting %s on removal queue",lisnrID(lisnr).c_str());
        }
        else // nothing to do, already removed from registration queue
        {
	 theseLogs.logNdev(1,"%s removed from registration queue",lisnrID(lisnr).c_str());
        }
    }
    else
    {
        assert(_removalQueue.empty());
        assert(_registrationQueue.empty());
        const bool removed = removeFrom(_registry, lisnr);
        assert(removed);
    }
}
Пример #2
0
IToplevelProtocol::~IToplevelProtocol()
{
  bool last = false;

  {
    MutexAutoLock al(*gProtocolMutex);

    for (IToplevelProtocol* actor = mOpenActors.getFirst();
         actor;
         actor = actor->getNext()) {
      actor->mOpener = nullptr;
    }

    mOpenActors.clear();

    if (mOpener) {
      removeFrom(mOpener->mOpenActors);
    }

    gNumProtocols--;
    last = gNumProtocols == 0;
  }

  if (last) {
    gProtocolMutex = nullptr;
  }
}
Пример #3
0
void 
EventSender<EvType>::registerListener(TListener* lisnr)
{
    if (_isBusySending)
    // use queues instead
    {
        // first see if it is on the removal queue
        if (! removeFrom(_removalQueue, lisnr))
        {
            // wasn't in removal queue, so put on registration queue
            // note that it shouldn't be possible to have listener 
            // register itself if it is already in the queue or registered
            assert(std::find(_registrationQueue.begin(), 
                   _registrationQueue.end(), lisnr) == _registrationQueue.end());
            _registrationQueue.push_back(lisnr);
           theseLogs.logNdev(1,"Putting %s on registration queue ",lisnrID(lisnr).c_str());
        }
        else // nothing to do, already in queue
        {
	 theseLogs.logNdev(1,"%s removed from registration queue",lisnrID(lisnr).c_str());
        }
    }
    else // safe to register immediately
    {
        // this method never called if already registerd, so assert this:
        assert(std::find(_registry.begin(), _registry.end(), lisnr)
                == _registry.end());
        
        _registry.push_back(lisnr);
       theseLogs.logNdev(1,"Added (immediate) %s to listeners list ",lisnrID(lisnr).c_str());
    }
}
Пример #4
0
void
EventSender<EvType>::cleanupQueues()
{
    assert(_isBusySending == false);
    
    // register listeners that have been queued for registration
    while (! _registrationQueue.empty()) 
    {
        typename Registry::iterator registryIter = _registrationQueue.begin();
       theseLogs.logNdev(1,"Registering queued %s ",lisnrID(*registryIter).c_str());
        // splice node from registration queue to registry
        _registry.splice(_registry.end(), _registrationQueue, registryIter);
        // make sure no other copy left in queue
        assert(std::find(_registrationQueue.begin(), 
                         _registrationQueue.end(), _registry.back()) 
               == _registrationQueue.end());
    }
    
    // remove listeners that have been queued for removal
    while (! _removalQueue.empty()) 
    {
        TListener* lisnr = _removalQueue.back();
        theseLogs.logNdev(1,"Removing queued %s ",lisnrID(lisnr).c_str());        
        if (! removeFrom(_registry, lisnr) )
	 theseLogs.logNdebug(1,"Listener %s not in registry, removal ignored.", lisnrID(lisnr).c_str());
        _removalQueue.pop_back();
    }
}
Пример #5
0
void
WebGLSampler::Delete()
{
    mContext->MakeContextCurrent();
    mContext->gl->fDeleteSamplers(1, &mGLName);

    removeFrom(mContext->mSamplers);
}
Пример #6
0
 void dfs(int& min_cost, int& cost, vector<int>& cart, vector<int>& needs, vector<vector<int>>& special, vector<int>& price) {
     if (overfit(cart, needs)) return;
     
     for (int i = 0; i < special.size(); ++i) {
         auto offer = special[i];
         addTo(cart, offer, cost, price, min_cost, needs, i);
         dfs(min_cost, cost, cart, needs, special, price);
         removeFrom(cart, offer, cost, i);
     }
 }
Пример #7
0
void MyList::remove(int element)
{
	if (empty()) {
		return;
	}

	int index = indexOf(element);
	if (index != -1) {
		removeFrom(index);
	}
}
Пример #8
0
	void GameLogicProcessor::onMessage(const MsgComponentDestroyed<GameLogicComponent>& msg)
	{
		GameLogicComponent* comp = gameLogicHolder->getComponent(msg.component);
		auto& pieces = comp->m_gamelogics;
		for (size_t i = 0; i < pieces.size(); ++i)
		{
			GameLogic* logic = pieces[i];
			GameLogic::RunEvents ev = logic->getRunEvents();
			if (ev & GameLogic::RunEvents::EFrameStart) {
				removeFrom(logic, m_onFrameStart);
			}

			if (ev & GameLogic::RunEvents::EFrameMiddle) {
				removeFrom(logic, m_onFrameMiddle);
			}

			if (ev & GameLogic::RunEvents::EFrameEnd) {
				removeFrom(logic, m_onFrameEnd);
			}

			logic->end();
		}
	}
Пример #9
0
IToplevelProtocol::~IToplevelProtocol()
{
  StaticMutexAutoLock al(gProtocolMutex);

  for (IToplevelProtocol* actor = mOpenActors.getFirst();
       actor;
       actor = actor->getNext()) {
    actor->mOpener = nullptr;
  }

  mOpenActors.clear();

  if (mOpener) {
      removeFrom(mOpener->mOpenActors);
  }
}
Пример #10
0
bool ObbFile::removeFrom(const char* filename)
{
    int fd;
    bool success = false;

    fd = ::open(filename, O_RDWR);
    if (fd < 0) {
        goto out;
    }
    success = removeFrom(fd);
    close(fd);

out:
    if (!success) {
        ALOGW("failed to remove signature from %s: %s\n", filename, strerror(errno));
    }
    return success;
}
Пример #11
0
/**
______________________________________________________
//  Remove frames , the frame are given as seen by GUI
//  We remove from start to end -1
// [start,end[
//______________________________________________________
*/
uint8_t ADM_Composer::removeFrames (uint32_t start, uint32_t end)
{

  uint32_t
    seg1,
    seg2,
    rel1,
    rel2;
  uint8_t
    lastone =
    0;

  if (end == _total_frames - 1)
    lastone = 1;

  // sanity check
  if (start > end)
    return 0;
  //if((1+start)==end) return 0;

  // convert frame to block, relative frame
  if (!convFrame2Seg (start, &seg1, &rel1) ||
      !convFrame2Seg (end, &seg2, &rel2))
    {
      assert (0);
    }
  // if seg1 != seg2 we can just modify seg1 and seg2
  if (seg1 != seg2)
    {
      // remove end of seg1

      removeFrom (rel1, seg1, 1);
      //  delete in between seg
      for (uint32_t seg = seg1 + 1; seg < (seg2); seg++)
	_segments[seg]._nb_frames = 0;
      // remove beginning of seg2
      removeTo (rel2, seg2, lastone);
    }
  else
    {
      // it is in the same segment, split it...
      // complete seg ?
      if ((rel1 == _segments[seg1]._start_frame)
	  && (rel2 ==
	      (_segments[seg1]._start_frame +
	       _segments[seg1]._nb_frames - 1)))
	{
	  _segments[seg1]._nb_frames = 0;
	}
      else
	{
	  // split in between.... duh !
	  duplicateSegment (seg1);
	  //
	  removeFrom (rel1, seg1, 1);
	  removeTo (rel2, seg1 + 1, lastone);
	}
    }

  // Crunch
  crunch ();
  sanityCheck ();
  // Compute total nb of frame
  _total_frames = computeTotalFrames ();
  printf ("\n %lu frames ", _total_frames);
  return 1;

}
Пример #12
0
void CArtifactInstance::move(ArtifactLocation src, ArtifactLocation dst)
{
	removeFrom(src);
	putAt(dst);
}