// This makes sure that the registries are consistent. void action_registry::fill_missing_typenames() { // Register all type-names and ssign missing ids for (std::string const& str : get_unassigned_typenames()) register_typename(str, ++max_id_); // Go over all registered mappings from type-names to ids and // fill in missing id to constructor mappings. for (auto const& d: typename_to_id_) { typename_to_ctor_t::const_iterator it = typename_to_ctor_.find(d.first); if (it != typename_to_ctor_.end()) cache_id(d.second, it->second); } // Go over all registered mappings from type-names to ctors and // fill in missing id to constructor mappings. for (auto const& d: typename_to_ctor_) { typename_to_id_t::const_iterator it = typename_to_id_.find(d.first); HPX_ASSERT(it != typename_to_id_.end()); cache_id(it->second, d.second); } }
void action_registry::register_factory(std::string const& type_name, ctor_t ctor) { HPX_ASSERT(ctor != nullptr); typename_to_ctor_.emplace(std::string(type_name), ctor); // populate cache typename_to_id_t::const_iterator it = typename_to_id_.find(type_name); if (it != typename_to_id_.end()) cache_id(it->second, ctor); }
void action_registry::register_typename( std::string const& type_name, std::uint32_t id) { HPX_ASSERT(id != invalid_id); std::pair<typename_to_id_t::iterator, bool> p = typename_to_id_.emplace(type_name, id); if (!p.second) { HPX_THROW_EXCEPTION(invalid_status, "action_registry::register_typename", "failed to insert " + type_name + " into typename to id registry."); } // populate cache typename_to_ctor_t::const_iterator it = typename_to_ctor_.find(type_name); if (it != typename_to_ctor_.end()) cache_id(id, it->second); if (id > max_id_) max_id_ = id; }
/* Implement the diskfs_lookup callback from the diskfs library. See <hurd/diskfs.h> for the interface specification. */ error_t diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, struct node **npp, struct dirstat *ds, struct protid *cred) { error_t err = 0; struct lookup_context ctx; int namelen; int spec_dotdot; void *buf; void *blockaddr; ino_t id; if ((type == REMOVE) || (type == RENAME)) assert (npp); if (npp) *npp = 0; spec_dotdot = type & SPEC_DOTDOT; type &= ~SPEC_DOTDOT; namelen = strlen (name); /* This error is constant, but the errors for CREATE and REMOVE depend on whether NAME exists. */ if (type == RENAME) return EROFS; buf = disk_image + (dp->dn->file_start << store->log2_block_size); for (blockaddr = buf; blockaddr < buf + dp->dn_stat.st_size; blockaddr += logical_sector_size) { err = dirscanblock (blockaddr, name, namelen, &ctx.dr, &ctx.rr); if (!err) break; if (err != ENOENT) return err; } if ((!err && type == REMOVE) || (err == ENOENT && type == CREATE)) err = EROFS; if (err) return err; err = cache_id (ctx.dr, &ctx.rr, &id); if (err) return err; /* Load the inode */ if (namelen == 2 && name[0] == '.' && name[1] == '.') { if (dp == diskfs_root_node) err = EAGAIN; else if (spec_dotdot) { /* renames and removes can't get this far. */ assert (type == LOOKUP); diskfs_nput (dp); err = diskfs_cached_lookup_context (id, npp, &ctx); } else { /* We don't have to do the normal rigamarole, because we are permanently read-only, so things are necessarily quiescent. Just be careful to honor the locking order. */ pthread_mutex_unlock (&dp->lock); err = diskfs_cached_lookup_context (id, npp, &ctx); pthread_mutex_lock (&dp->lock); } } else if (namelen == 1 && name[0] == '.') { *npp = dp; diskfs_nref (dp); } else err = diskfs_cached_lookup_context (id, npp, &ctx); release_rrip (&ctx.rr); return err; }