void KQueue::unsubscribe(const Fd &fd) { // invalidate(fd); flush_changes(); add_change(fd.get_native_fd(), EVFILT_READ, EV_DELETE, 0, 0, nullptr); flush_changes(true); add_change(fd.get_native_fd(), EVFILT_WRITE, EV_DELETE, 0, 0, nullptr); flush_changes(true); }
void KQueue::subscribe(const Fd &fd, Fd::Flags flags) { if (flags & Fd::Read) { add_change(fd.get_native_fd(), EVFILT_READ, EV_ADD | EV_CLEAR, 0, 0, nullptr); } if (flags & Fd::Write) { add_change(fd.get_native_fd(), EVFILT_WRITE, EV_ADD | EV_CLEAR, 0, 0, nullptr); } }
//############################################################################## //############################################################################## bool BerkeleyDBCXXDb::write_record(record_type type, const std::string &key, uint64_t object_version, const std::string &data) { RANGE_LOG_FUNCTION(); auto txn = boost::dynamic_pointer_cast<BerkeleyDBCXXTxn>(this->start_txn()); return txn->add_change(std::make_tuple(type, key, object_version, data)); }
/** * @brief Allocates a new slot for a texture and returns a shared pointer to the new slot. * Slot lifetime is tied to the pointer's lifetime. * * @param tex Texture to insert */ auto allocate_slot(texture_t &&tex, image_layout layout = default_layout) { // Find a location for the slot: If there are tombstones, replace one of them with new element, if possible optional<std::uint32_t> location; { std::unique_lock<std::mutex> l(tombstones_mutex); if (tombstones.size()) { location = std::prev(tombstones.end())->start; tombstones.pop_back(); } } // If no tombstones, use a location past the vector's end. if (!location) location = count.fetch_add(1); // Create slot and pipeline image, we can do that without a lock value_type val = lib::allocate_shared<slot_t>(slot_t::token(), std::move(tex), *this, location.get()); auto img = image_t(val->tex, layout); // Update changes data { std::unique_lock<std::mutex> l(general_mutex); add_change(location.get(), std::move(img)); } return val; }
int sector_add_3do(int objectid, int local_id) { int sector_no=sector_get(objects_list[objectid]->x_pos, objects_list[objectid]->y_pos); if(sector_no>=num_sectors) return -1; sectors[sector_no].e3d_local[local_id]=objectid; add_change(); return local_id; }
void end_change_chain(void) { if (change_barrier) { /* There were no changes in this change chain. */ free(change_barrier); change_barrier = NULL; } else { /* There were some changes. Add end of chain marker. */ add_change(alloc_change()); } }
int sector_add_particle(int objectid, int local_id) { int sector_no=sector_get(particles_list[objectid]->x_pos, particles_list[objectid]->y_pos); if(sector_no>=num_sectors) return -1; sectors[sector_no].particles_local[local_id]=objectid; add_change(); return local_id; }
static struct change *new_change(void) { struct change *change; if (change_barrier) { /* * We are recording series of changes (:replace for example) * and now we have just made the first change so we have to * mark beginning of the chain. * * We could have done this before when starting the change * chain but then we may have ended up with an empty chain. * We don't want to record empty changes ever. */ add_change(change_barrier); change_barrier = NULL; } change = alloc_change(); add_change(change); return change; }
int sector_add_light(int objectid) { int i; int sector_no=sector_get(lights_list[objectid]->pos_x, lights_list[objectid]->pos_y); if(sector_no>=num_sectors) return -1; for(i=0;i<MAX_LIGHTS_PER_SECTOR;i++){ if(sectors[sector_no].lights_local[i]==-1){ sectors[sector_no].lights_local[i]=objectid; add_change(); return i; } } return -1; }
bool WLivelinessPeriodicAssertion::ManualByRTPSParticipantLivelinessAssertion() { std::lock_guard<std::recursive_mutex> guard(*this->mp_WLP->getBuiltinProtocols()->mp_PDP->getMutex()); bool livelinessAsserted = false; for(std::vector<RTPSWriter*>::iterator wit=this->mp_WLP->m_livManRTPSParticipantWriters.begin(); wit!=this->mp_WLP->m_livManRTPSParticipantWriters.end();++wit) { if((*wit)->getLivelinessAsserted()) { livelinessAsserted = true; } (*wit)->setLivelinessAsserted(false); } if(livelinessAsserted) { auto writer = this->mp_WLP->getBuiltinWriter(); auto history = this->mp_WLP->getBuiltinWriterHistory(); std::lock_guard<std::recursive_timed_mutex> wguard(writer->getMutex()); CacheChange_t* change=writer->new_change([]() -> uint32_t {return BUILTIN_PARTICIPANT_DATA_MAX_SIZE;}, ALIVE); if(change!=nullptr) { change->instanceHandle = m_iHandle; #if __BIG_ENDIAN__ change->serializedPayload.encapsulation = (uint16_t)PL_CDR_BE; #else change->serializedPayload.encapsulation = (uint16_t)PL_CDR_LE; #endif memcpy(change->serializedPayload.data,m_guidP.value,12); for(uint8_t i =12;i<24;++i) change->serializedPayload.data[i] = 0; change->serializedPayload.data[15] = m_livelinessKind+1; change->serializedPayload.length = 12+4+4+4; for(auto ch = history->changesBegin(); ch!=history->changesEnd();++ch) { if((*ch)->instanceHandle == change->instanceHandle) { history->remove_change(*ch); } } history->add_change(change); } } return false; }
bool WLivelinessPeriodicAssertion::AutomaticLivelinessAssertion() { std::lock_guard<std::recursive_mutex> guard(*this->mp_WLP->getBuiltinProtocols()->mp_PDP->getMutex()); if(this->mp_WLP->m_livAutomaticWriters.size()>0) { auto writer = this->mp_WLP->getBuiltinWriter(); auto history = this->mp_WLP->getBuiltinWriterHistory(); std::lock_guard<std::recursive_timed_mutex> wguard(writer->getMutex()); CacheChange_t* change=writer->new_change([]() -> uint32_t {return BUILTIN_PARTICIPANT_DATA_MAX_SIZE;}, ALIVE,m_iHandle); if(change!=nullptr) { //change->instanceHandle = m_iHandle; #if __BIG_ENDIAN__ change->serializedPayload.encapsulation = (uint16_t)PL_CDR_BE; #else change->serializedPayload.encapsulation = (uint16_t)PL_CDR_LE; #endif memcpy(change->serializedPayload.data,m_guidP.value,12); for(uint8_t i =12;i<24;++i) change->serializedPayload.data[i] = 0; change->serializedPayload.data[15] = m_livelinessKind+1; change->serializedPayload.length = 12+4+4+4; if(history->getHistorySize() > 0) { for(std::vector<CacheChange_t*>::iterator chit = history->changesBegin(); chit!=history->changesEnd();++chit) { if((*chit)->instanceHandle == change->instanceHandle) { history->remove_change(*chit); break; } } } history->add_change(change); } } return true; }