void event_poll::handle_poll() { int event_cnt; while (looping()) { event_cnt = _poll.poll(_event, 1000); while (event_cnt > 0) { io_epoll::event ev = _event.at(static_cast<size_t>(--event_cnt)); tunnel * tun = (tunnel *)ev.data.ptr; if (io_epoll::ev_error(ev)) { event_remove(tun); } else { if (io_epoll::ev_recv(ev)) { event_recv(tun); } if (io_epoll::ev_send(ev)) { event_send(tun); } } } handle_event(); } }
void event_poll::start() { looping(); std::thread loop([this](){ handle_poll(); }); loop.detach(); }
void ArenaLocker::_loadSounds(std::string fileName, SoundManager* Sound) { auto sndList = soundList(fileName.c_str()); sSound sound; for(auto itr = sndList->sound().begin(); itr != sndList->sound().end(); ++itr) { sound.is3D = itr->is3D(); sound.isLooping = itr->looping(); sound.name = itr->name(); Sound->createSound(sound,itr->filename().c_str()); _sounds.push_back(sound); } return; }
void ThreadRunner::run() { // this is the body of execution of separate thread boost::mutex::scoped_lock lock(m_runmutex); try{ workerThrew=false; while(looping()) { call(); if(m_thread_worker->shouldTerminate()){ stop(); return; } } } catch (std::exception& e){ LOG_FATAL("Exception occured: "<<std::endl<<e.what()); workerException=std::exception(e); workerThrew=true; stop(); return; } }
void event_poll::wait() { while (looping() == true); }