//! Warn: only call in single-consumer thread. gsl::owner<T*> get() noexcept override { auto n = pri_get(); if (n == nullptr) { n = pmk_(); } if (n != nullptr) { n->on_get(this); } return (T*)n; }
~mpsc_pool() noexcept { while (true) { auto n = pri_get(); if (!n) { break; } n->on_get(nullptr); n->release(); } }
void mesh_on_discover(mesh_t mesh, char *id, link_t (*discover)(mesh_t mesh, lob_t discovered, pipe_t pipe)) { on_t on = on_get(mesh, id); if(on) on->discover = discover; }
void mesh_on_open(mesh_t mesh, char *id, lob_t (*open)(link_t link, lob_t open)) { on_t on = on_get(mesh, id); if(on) on->open = open; }
void mesh_on_link(mesh_t mesh, char *id, void (*link)(link_t link)) { on_t on = on_get(mesh, id); if(on) on->link = link; }
void mesh_on_path(mesh_t mesh, char *id, pipe_t (*path)(link_t link, lob_t path)) { on_t on = on_get(mesh, id); if(on) on->path = path; }
void mesh_on_free(mesh_t mesh, char *id, void (*free)(mesh_t mesh)) { on_t on = on_get(mesh, id); if(on) on->free = free; }