void ExtensionMgr::loadExtension(const KService::Ptr& service) {
  int err = 0;
  QString name = service->property("Name").toString();
  KstExtension *e = KParts::ComponentFactory::createInstanceFromService<KstExtension>(service, _window, 0, QStringList(), &err);
  if (e) {
    connect(e, SIGNAL(unregister()), this, SLOT(unregister()));
    KstDebug::self()->log(i18n("Kst Extension %1 loaded.").arg(name));
    doRegister(name,e);
  } else {
    KstDebug::self()->log(i18n("Error trying to load Kst extension %1.  Code=%2, \"%3\"").arg(name).arg(err).arg(err == KParts::ComponentFactory::ErrNoLibrary ? i18n("Library not found [%1].").arg(KLibLoader::self()->lastErrorMessage()) : KLibLoader::self()->lastErrorMessage()), KstDebug::Error);
  }
}
ComponentMovementWatcher::~ComponentMovementWatcher()
{
    if (component != nullptr)
        component->removeComponentListener (this);

    unregister();
}
void ComponentMovementWatcher::componentBeingDeleted (Component& comp)
{
    registeredParentComps.removeValue (&comp);

    if (component == &comp)
        unregister();
}
Exemple #4
0
void LVL_Npc::deActivate()
{
    if(!wasDeactivated)
        wasDeactivated = true;

    if(!isActivated) return;

    isActivated = false;

    if(!is_shared_animation)
        animator.stop();

    if(!keep_position_on_despawn)
    {
        if(!reSpawnable)
            unregister();
        else
        {
            if(data.id != _npc_id)
            {
                transformTo_x(data.id); //Transform NPC back into initial form
            }

            setDefaults();
            setPos(data.x, data.y);
            setDirection(data.direct);
            setPaused(true);
            m_momentum.saveOld();
        }
    }
}
Exemple #5
0
	/// Connection base state machine
	void nextOperation()
	{
		NetworkOperation netOp = m_connHandler->nextOperation();
		switch ( netOp.operation() )	{
			case NetworkOperation::READ:	{
				LOG_TRACE << "Next operation: READ " << netOp.size() << " bytes from " << identifier();
				if ( netOp.buffer() == NULL )	{
					LOG_FATAL << "Attempt to READ from " << identifier() << " to a NULL data block";
					abort();		// here should be a system exception
				}
				if ( netOp.size() == 0 )	{
					LOG_FATAL << "Attempt to READ 0 bytes data block from " << identifier();
					abort();		// here should be a system exception
				}
				if ( netOp.timeout() > 0 )
					setTimeout( netOp.timeout());
				m_readBuffer = netOp.buffer();
				socket().async_read_some( boost::asio::buffer( m_readBuffer, netOp.size() ),
							  m_strand.wrap( boost::bind( &ConnectionBase::handleRead,
										      this->shared_from_this(),
										      boost::asio::placeholders::error,
										      boost::asio::placeholders::bytes_transferred )));
				break;
			}

			case NetworkOperation::WRITE:	{
				LOG_TRACE << "Next operation: WRITE " << netOp.size() << " bytes to " << identifier();
				if ( netOp.data() == NULL )	{
					LOG_FATAL << "Attempt to WRITE a NULL data block to " << identifier();
					abort();		// here should be a system exception
				}
				if ( netOp.size() == 0 )	{
					LOG_FATAL << "Attempt to WRITE a 0 bytes data block to " << identifier();
					abort();		// here should be a system exception
				}
				if ( netOp.timeout() > 0 )
					setTimeout( netOp.timeout());
				boost::asio::async_write( socket(),
							  boost::asio::buffer( netOp.data(), netOp.size() ),
							  m_strand.wrap( boost::bind( &ConnectionBase::handleWrite,
										      this->shared_from_this(),
										      boost::asio::placeholders::error )));
				break;
			}

			case NetworkOperation::CLOSE:	{
				LOG_TRACE << "Next operation: CLOSE connection to " << identifier();
				// Initiate graceful connection closure.
				setTimeout( 0 );
				unregister();
				m_strand.post( boost::bind( &ConnectionBase::handleShutdown,
							    this->shared_from_this() ));
				break;
			}

			case NetworkOperation::NOOP:
				LOG_TRACE << "Next operation: NOOP on connection to " << identifier();
				break;
		}
	}
Exemple #6
0
void handle_unregisterX(lua::state& L, uint64_t addr, int lfn)
{
    lua_debug_callback_dict* Dx;
    lua_debug_callback2* D = NULL;
    L.pushlightuserdata(&CONST_lua_cb_list_key);
    L.rawget(LUA_REGISTRYINDEX);
    if(!L.isnil(-1)) {
        Dx = (lua_debug_callback_dict*)L.touserdata(-1);
        auto key = std::make_pair(type, addr);
        if(Dx->cblist.count(key))
            D = Dx->cblist[key];
        L.pop(1);
        while(D) {
            if(D->dead || D->type != type || D->addr != addr || L.topointer(lfn) != D->lua_fn) {
                D = D->next;
                continue;
            }
            //Remove this.
            auto Dold = D;
            D = D->next;
            Dold->unregister();
        }
    } else
        L.pop(1);
}
Exemple #7
0
void MemoryManager::sweep() {
  assert(!sweeping());
  if (debug) checkHeap();
  if (debug) traceHeap();
  m_sweeping = true;
  SCOPE_EXIT { m_sweeping = false; };
  DEBUG_ONLY size_t num_sweepables = 0, num_natives = 0;

  // iterate until both sweep lists are empty. Entries can be added or
  // removed from either list during sweeping.
  do {
    while (!m_sweepables.empty()) {
      num_sweepables++;
      auto obj = m_sweepables.next();
      obj->unregister();
      obj->sweep();
    }
    while (!m_natives.empty()) {
      num_natives++;
      assert(m_natives.back()->sweep_index == m_natives.size() - 1);
      auto node = m_natives.back();
      m_natives.pop_back();
      auto obj = Native::obj(node);
      auto ndi = obj->getVMClass()->getNativeDataInfo();
      ndi->sweep(obj);
      // trash the native data but leave the header and object parsable
      assert(memset(node+1, kSmartFreeFill, node->obj_offset - sizeof(*node)));
    }
  } while (!m_sweepables.empty());

  TRACE(1, "sweep: sweepable %lu native %lu\n", num_sweepables, num_natives);
  if (debug) checkHeap();
}
DefinitionWatcher::~DefinitionWatcher() {
    if (registered_to.size() > 0) {
        Logs::error("Definition")
            << "Watcher still registered at destruction, forcing potentially harmful unregister : " << name << endl;
        unregister();
    }
}
//==============================================================================
void ComponentMovementWatcher::componentParentHierarchyChanged (Component&)
{
    if (component != nullptr && ! reentrant)
    {
        const ScopedValueSetter<bool> setter (reentrant, true);

        ComponentPeer* const peer = component->getPeer();
        const uint32 peerID = peer != nullptr ? peer->getUniqueID() : 0;

        if (peerID != lastPeerID)
        {
            componentPeerChanged();

            if (component == nullptr)
                return;

            lastPeerID = peerID;
        }

        unregister();
        registerWithParentComps();

        componentMovedOrResized (*component, true, true);

        if (component != nullptr)
            componentVisibilityChanged (*component);
    }
}
Exemple #10
0
	void LogStreamNotifier::registerAt(LogStream& log, int min_level, int max_level)
	{
		unregister();

		registered_at_ = &log;
		log.insertNotification(stream_, *this, min_level, max_level);
	}
	Decal::~Decal()
	{
		unregister();

		mSceneNode->getParentSceneNode()->removeAndDestroyChild(mSceneNode->getName());

		delete mProjector;
	}
	void Decal::setVisible(const bool& Visible)
	{
		mVisible = Visible;

		unregister();

		mHydrax->getDecalsManager()->_forceToUpdate();
	}
void stopInjectionPins(void) {
	for (int i = 0; i < INJECTION_PIN_COUNT; i++) {
		NamedOutputPin *output = &enginePins.injectors[i];
		brain_pin_e currentPin = activeConfiguration.bc.injectionPins[i];
		if (engineConfiguration->bc.injectionPins[i] != currentPin) {
			unregister(currentPin, output);
		}
	}
}
ftrace_decode_ascii::~ftrace_decode_ascii(void)
{
	int i;
	for (i = 0; i < events_max; i++)
	{
		while (events[i].event_name != NULL)
			unregister(events[i].event_name, events[i].callback->fn);
	}
}
Exemple #15
0
void sig_int(int sig) {
	if (sig==SIGINT){    
		if(unregister()<0) 
		cout<<"De-registeration Failed\n";
	else 
		cout<<"Server has been de-registered successfully\n";
		exit(0);		
	}
}
Exemple #16
0
IdRegister::~IdRegister()
{
    auto ircs = hashmap.values();
    if (freeEverythingAtDestroyVal){
        for (IdRegisteredClass* irc : ircs)
            delete irc;
    } else {
        for (IdRegisteredClass* irc : ircs)
            unregister(irc);
    }
}
Exemple #17
0
static int w_unregister(struct sip_msg* _m, char* _d, char* _uri)
{
	str uri = {0};
	if(fixup_get_svalue(_m, (gparam_p)_uri, &uri)!=0 || uri.len<=0)
	{
		LM_ERR("invalid uri parameter\n");
		return -1;
	}

	return unregister(_m, (udomain_t*)_d, &uri, NULL);
}
			~cv_cancellation_guard()
			{
				if (!_registered || RETHREAD_LIKELY(try_unregister(_token, _handler)))
					return;

				// We need to unlock mutex before unregistering, because canceller thread
				// can get stuck at mutex in cv_cancellation_handler::cancel().
				// When unregister returns, we are sure that canceller has left cancel(), so it is safe to lock mutex back.
				reverse_lock<typename Handler::lock_type> ul(_handler.get_lock());
				unregister(_token, _handler);
			}
Exemple #19
0
static gboolean shutdown_handler(GtkApplication *app, gpointer data)
{
	gmpv_mpris *inst = data;

	g_signal_handler_disconnect(app, inst->shutdown_sig_id);

	unregister(inst);
	g_bus_unown_name(inst->name_id);
	g_free(inst);

	return FALSE;
}
void c_ExternalThreadEventWaitHandle::abandon(bool sweeping) {
  assert(getState() == STATE_WAITING);
  assert(getCount() == 1 || sweeping);

  if (isInContext()) {
    getContext()->unregisterExternalThreadEvent(m_index);
  }

  // event is abandoned, destroy it, unregister sweepable and decref ownership
  m_event->release();
  m_event = nullptr;
  unregister();
  decRefObj(this);
}
Exemple #21
0
void ViewManager::viewDying( View * view )
//----------------------------------------
{
    if( view->identity() == VIDetailView ) {
        _detailViews->remove( (DetailView *) view );
    }

    unregister( view );

    eventOccured( VELosingFocus, view );
    eventOccured( VEClose, view );

    _killList->append( view );      // will be deleted next event
}
void c_ExternalThreadEventWaitHandle::destroyEvent(bool sweeping /*= false */) {
  // destroy event and its private data
  m_event->release();
  m_event = nullptr;

  // unregister from sweep()
  unregister();

  if (LIKELY(!sweeping)) {
    m_privData = nullptr;
    // drop ownership by pending event (see initialize())
    decRefObj(this);
  }
}
void MemoryManager::sweep() {
  // running a gc-cycle at end of request exposes bugs, but otherwise is
  // somewhat pointless since we're about to free the heap en-masse.
  if (debug) collect("before MM::sweep");

  assert(!sweeping());
  m_sweeping = true;
  DEBUG_ONLY size_t num_sweepables = 0, num_natives = 0;

  // iterate until both sweep lists are empty. Entries can be added or
  // removed from either list during sweeping.
  do {
    while (!m_sweepables.empty()) {
      num_sweepables++;
      auto obj = m_sweepables.next();
      obj->unregister();
      obj->sweep();
    }
    while (!m_natives.empty()) {
      num_natives++;
      assert(m_natives.back()->sweep_index == m_natives.size() - 1);
      auto node = m_natives.back();
      m_natives.pop_back();
      auto obj = Native::obj(node);
      auto ndi = obj->getVMClass()->getNativeDataInfo();
      ndi->sweep(obj);
      // trash the native data but leave the header and object parsable
      assert(memset(node+1, kSmallFreeFill, node->obj_offset - sizeof(*node)));
    }
  } while (!m_sweepables.empty());

  DEBUG_ONLY auto napcs = m_apc_arrays.size();
  FTRACE(1, "sweep: sweepable {} native {} apc array {}\n",
         num_sweepables,
         num_natives,
         napcs);

  // decref apc arrays referenced by this request.  This must happen here
  // (instead of in resetAllocator), because the sweep routine may use
  // g_context.
  while (!m_apc_arrays.empty()) {
    auto a = m_apc_arrays.back();
    m_apc_arrays.pop_back();
    a->sweep();
    if (debug) a->m_sweep_index = kInvalidSweepIndex;
  }

  if (debug) checkHeap("after MM::sweep");
}
Exemple #24
0
static gboolean delete_handler(	GtkWidget *widget,
				GdkEvent *event,
				gpointer data )
{
	gmpv_mpris *inst = data;
	GmpvMainWindow *wnd = gmpv_application_get_main_window(inst->gmpv_ctx);

	g_signal_handler_disconnect(wnd, inst->shutdown_sig_id);

	unregister(inst);
	g_bus_unown_name(inst->name_id);
	g_free(inst);

	return FALSE;
}
Exemple #25
0
static int ki_unregister_ruid(sip_msg_t* _m, str* _dtable, str* _uri, str *_ruid)
{
	udomain_t* d;

	if(_uri==NULL || _uri->len<=0) {
		LM_ERR("invalid uri parameter\n");
		return -1;
	}
	if(ul.get_udomain(_dtable->s, &d)<0) {
		LM_ERR("usrloc domain [%s] not found\n", _dtable->s);
		return -1;
	}

	return unregister(_m, d, _uri, _ruid);
}
Exemple #26
0
/*
 * Unregisteres the specified component and its children.
 */
static void
unregister(Wsreg_component *comp)
{
	if (comp != NULL) {
		Wsreg_component **children = wsreg_get_child_components(comp);
		wsreg_unregister(comp);
		if (children != NULL) {
			int index = 0;
			while (children[index] != NULL) {
				unregister(children[index]);
				index++;
			}
			wsreg_free_component_array(children);
		}
	}
}
Exemple #27
0
/**
 * The main function.
 */
int main()
{
    /* Seeding random number generator */
    srand( time(NULL) );

    int my_pid = getpid();
    unsigned int period = get_period();
    unsigned int computation_time = get_comp_time(period);

    register_process(my_pid, period, computation_time);

    if(!is_registered(my_pid))
    {
        printf("%d: I was unable to register.  ;_;\n", my_pid);
        exit(1);
    }
    printf("%d: Registered! \n", my_pid);

    unsigned int iterations = get_iterations();
    yield(my_pid);

    while(iterations > 0)
    {
        struct timeval time;
        gettimeofday(&time);
        unsigned int start_time = time.tv_usec;

        unsigned int time_elapsed = 0;
        while(time_elapsed < computation_time)
        {
            int i;
            for(i = 0; i < 100; i++)
            {
                factorial((i % 20)+1);
            }
            gettimeofday(&time);
            time_elapsed = time.tv_usec - start_time;
        }

        yield(my_pid);
        iterations--;
    }

    unregister(my_pid);
    return 0;
}
Exemple #28
0
void MemoryManager::sweep() {
  assert(!sweeping());
  if (debug) checkHeap();
  collect();
  m_sweeping = true;
  SCOPE_EXIT { m_sweeping = false; };
  DEBUG_ONLY size_t num_sweepables = 0, num_natives = 0;

  // iterate until both sweep lists are empty. Entries can be added or
  // removed from either list during sweeping.
  do {
    while (!m_sweepables.empty()) {
      num_sweepables++;
      auto obj = m_sweepables.next();
      obj->unregister();
      obj->sweep();
    }
    while (!m_natives.empty()) {
      num_natives++;
      assert(m_natives.back()->sweep_index == m_natives.size() - 1);
      auto node = m_natives.back();
      m_natives.pop_back();
      auto obj = Native::obj(node);
      auto ndi = obj->getVMClass()->getNativeDataInfo();
      ndi->sweep(obj);
      // trash the native data but leave the header and object parsable
      assert(memset(node+1, kSmallFreeFill, node->obj_offset - sizeof(*node)));
    }
  } while (!m_sweepables.empty());

  DEBUG_ONLY auto napcs = m_apc_arrays.size();
  FTRACE(1, "sweep: sweepable {} native {} apc array {}\n",
         num_sweepables,
         num_natives,
         napcs);
  if (debug) checkHeap();

  // decref apc arrays referenced by this request.  This must happen here
  // (instead of in resetAllocator), because the sweep routine may use
  // g_context.
  while (!m_apc_arrays.empty()) {
    auto a = m_apc_arrays.back();
    m_apc_arrays.pop_back();
    a->sweep();
  }
}
Exemple #29
0
static int w_unregister2(struct sip_msg* _m, char* _d, char* _uri, char *_ruid)
{
	str uri = {0, 0};
	str ruid = {0};
	if(fixup_get_svalue(_m, (gparam_p)_uri, &uri)!=0)
	{
		LM_ERR("invalid uri parameter\n");
		return -1;
	}
	if(fixup_get_svalue(_m, (gparam_p)_ruid, &ruid)!=0 || ruid.len<=0)
	{
		LM_ERR("invalid ruid parameter\n");
		return -1;
	}

	return unregister(_m, (udomain_t*)_d, &uri, &ruid);
}
	void Decal::registerPass(Ogre::Pass* _Pass)
	{
		unregister();

		_Pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
		_Pass->setCullingMode(Ogre::CULL_NONE);
        _Pass->setDepthBias(1,1);
        _Pass->setLightingEnabled(false);
		_Pass->setDepthWriteEnabled(false);

		Ogre::TextureUnitState *DecalTexture = _Pass->createTextureUnitState(mTextureName);
        DecalTexture->setProjectiveTexturing(true, mProjector);
		DecalTexture->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
		DecalTexture->setTextureFiltering(Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE);
		DecalTexture->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_TEXTURE, Ogre::LBS_MANUAL, 1.0, mTransparency);

		mRegisteredPass = _Pass;
	}