std::shared_ptr<T> pop() { std::lock_guard<std::mutex> _lock_(m_mutex); if(m_queue.empty()) { return std::shared_ptr<T>(); } else { std::shared_ptr<T> tmpm(std::move(m_queue.front())); m_queue.pop_front(); return tmpm; } }
void LuaValue::setTable() { if (bool(data_)==false) { return; } auto ls__=data_->luaState_.lock(); if (bool(ls__)==false) { return; } lua_State * L=ls__.get(); __cct::__private::TopLock _lock_(L); if (lua_istable(L,-1)) { const int value_pos_=lua_gettop(L); _setValue<Type_Table>(L); lua_rawgetp(L,LUA_REGISTRYINDEX,getTablePathPointer(Type_Table)); if (lua_istable(L,-1)==false) { lua_pop(L,1); lua_newtable(L); lua_pushvalue(L,-1); lua_rawsetp(L,LUA_REGISTRYINDEX,getTablePathPointer(Type_Table)); } lua_pushvalue(L,value_pos_); lua_rawseti(L,-2,data_->pointer_); } }
/*--------------------------------------------------------------------------* * --- Elire une tache --- * * Entree : Numero de la tache * * Sortie : Neant * * Descrip: Cette procedure place une tache dans la file d'attente des * * taches eligibles. * * Les activations ne sont pas memorisee * * Err. fatale: Tache inconnue * * * *--------------------------------------------------------------------------*/ void active(uint16_t tache) { CONTEXTE *p = &_contexte[tache]; /* acces au contexte tache */ if (p->status == NCREE) { /* sortie du noyau */ noyau_exit(); } /* debut section critique */ _lock_(); /* n'active que si receptif */ if (p->status == CREE) { /* changement d'etat, mise a l'etat PRET */ p->status = PRET; /* ajouter la tache dans la liste */ ajoute(tache); /* activation d'une tache prete */ } /* fin section critique */ _unlock_(); }
/*--------------------------------------------------------------------------* * --- Provoquer une commutation --- * *--------------------------------------------------------------------------*/ void schedule(void) { /* Debut section critique */ _lock_(); _ack_timer = 0; /* On simule une exception irq pour forcer * un appel correct à scheduler().*/ /* Passer en mode IRQ */ _set_arm_mode_(ARMMODE_IRQ); __asm__ __volatile__( /* Sauvegarder cpsr dans spsr */ "mrs r0, CPSR\t\n" "msr SPSR, r0\t\n" /* Sauvegarder pc dans lr et l'ajuster */ "add lr, pc, #4\t\n" // TODO voir s'il ne faut pas mettre 8 /* Saut à scheduler */ "b scheduler" :::"r0"); /* Repasser en mode system */ _set_arm_mode_(ARMMODE_SYS); /* Fin section critique */ _unlock_(); }
/** * pushes a new object to the back of the queue * @param in a shared pointer to the object (as r-value reference) */ void push(std::shared_ptr<T>&& in) { std::lock_guard<std::mutex> _lock_(m_mutex); m_queue.push_back(std::move(in)); }
/** * removes all of the pointers to a given object * @param in const reference to the object to be removed (for computing the address only) */ void remove(const T& in) { std::lock_guard<std::mutex> _lock_(m_mutex); m_queue.erase(std::remove_if(m_queue.begin(),m_queue.end(),remover(in)), m_queue.end()); }