MCPcopy Create free account
hub / github.com/DFHack/dfhack / connect

Method connect

plugins/devel/kittens.cpp:243–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241 this->id = id;
242 }
243 void connect(color_ostream& o, shared& b, size_t pos, uint32_t c)
244 {
245 out = &o;
246 count = c*2;
247 other = b;
248 other_sig = b->signal.weak_from_this();
249 // Externally synchronized object destruction is only safe to this
250 // connect.
251 con[pos] = b->signal.connect(
252 [this](uint32_t) {
253 uint32_t old = callee.fetch_add(1);
254 assert(old != 0xDEDEDEDE); (void)old;
255 std::this_thread::sleep_for(delay);
256 assert(callee != 0xDEDEDEDE);
257 });
258 // Shared object managed object with possibility of destruction while
259 // other threads calling emit must pass the shared_ptr to connect.
260 Connected *bptr = b.get();
261 b->con[pos] = signal.connect(b,
262 [bptr](int) {
263 uint32_t old = bptr->callee.fetch_add(1);
264 assert(old != 0xDEDEDEDE); (void)old;
265 std::this_thread::sleep_for(delay);
266 assert(bptr->callee != 0xDEDEDEDE);
267 });
268 }
269 void reconnect(size_t pos) {
270 auto b = other.lock();
271 if (!b)

Callers 3

connectToMethod · 0.45
reconnectMethod · 0.45
sharedsignalFunction · 0.45

Calls 2

weak_from_thisMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected