OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace-cog commits / 9c831d1

Revert changes that were not meant to be merged yet.
I must be getting tired. I merged the wrong branch into master. Its tangled so I'm just gonna unclobber.
9c831d17c49d34fd2d88a5bb87ce24ce17c59829
by Linas Vepštas <linasvepstas@gmail.com> · 2025-12-07T06:16:49.000Z

Changed files (3) +30 -11

opencog/persist/cog-simple/CogSimpleIO.cc +12 -0
……@@ -94,6 +94,9 @@ void CogSimpleStorage::storeAtom(const Handle& h, bool synchronous)
9494
9595 std::lock_guard<std::mutex> lck(_mtx);
9696 do_send(msg);
97
98 // Flush the response.
99 do_recv();
97100}
98101
99102void CogSimpleStorage::storeValue(const Handle& h, const Handle& key)
……@@ -111,6 +114,9 @@ void CogSimpleStorage::storeValue(const Handle& h, const Handle& key)
111114
112115 std::lock_guard<std::mutex> lck(_mtx);
113116 do_send(msg);
117
118 // Flush the response.
119 do_recv();
114120}
115121
116122void CogSimpleStorage::updateValue(const Handle& h, const Handle& key,
……@@ -129,6 +135,9 @@ void CogSimpleStorage::updateValue(const Handle& h, const Handle& key,
129135
130136 std::lock_guard<std::mutex> lck(_mtx);
131137 do_send(msg);
138
139 // Flush the response.
140 do_recv();
132141}
133142
134143void CogSimpleStorage::loadValue(const Handle& h, const Handle& key)
……@@ -370,6 +379,9 @@ std::string CogSimpleStorage::writeFrame(const Handle& hasp)
370379 {
371380 std::lock_guard<std::mutex> lck(_mtx);
372381 do_send(msg);
382
383 // Flush the response.
384 do_recv();
373385 }
374386
375387 // Store short-forms
opencog/persist/cog-storage/CogChannel.cc +12 -8
……@@ -385,18 +385,22 @@ void CogChannel<Client, Data>::reply_handler(const Msg& msg)
385385template<typename Client, typename Data>
386386void CogChannel<Client, Data>::barrier()
387387{
388 // Generate a unique barrier ID
388 // Drain work queues.
389 _msg_buffer.barrier();
390
391 // Server can complete barrier only after it receives it on
392 // all of the open sockets; the random string is the uuid to
393 // disambiguate this barrier from any others that might get
394 // issued. The barrier is retired after all N of them are received.
389395 static thread_local std::minstd_rand rng(std::random_device{}());
390396 uint64_t rnd = (uint64_t(rng()) << 32) | rng();
391397
392 // Build the barrier message. Each worker thread will send this,
393 // opening its socket if needed. Server completes when all N arrive.
398 std::lock_guard<std::mutex> lck(_sock_set_mtx);
394399 char msg[64];
395 snprintf(msg, sizeof(msg), "(cog-barrier %u \"%016lx\")\n", NTHREADS, rnd);
396
397 Data dummy = Data();
398 Msg block{nullptr, nullptr, true, msg, dummy};
399 _msg_buffer.barrier(block);
400 snprintf(msg, sizeof(msg), "(cog-barrier %zu \"%016lx\")\n",
401 _open_socks.size(), rnd);
402 for (int sockfd : _open_socks)
403 send(sockfd, msg, strlen(msg), MSG_NOSIGNAL);
400404}
401405
402406template<typename Client, typename Data>
opencog/persist/cog-storage/CogIO.cc +6 -3
……@@ -91,7 +91,8 @@ void CogStorage::storeAtom(const Handle& h, bool synchronous)
9191 msg = "(cog-set-value! " + Sexpr::encode_atom(h) +
9292 "(Predicate \"*-TruthValueKey-*\") #f)\n";
9393
94 _io_queue.enqueue_noreply(msg);
94 Pkt pkt;
95 _io_queue.enqueue(this, msg, pkt, &CogStorage::noop_const);
9596}
9697
9798void CogStorage::removeAtom(AtomSpace* frame, const Handle& h, bool recursive)
……@@ -115,7 +116,8 @@ void CogStorage::storeValue(const Handle& h, const Handle& key)
115116 Sexpr::encode_atom(key) +
116117 Sexpr::encode_value(h->getValue(key)) + ")\n";
117118
118 _io_queue.enqueue_noreply(msg);
119 Pkt pkt;
120 _io_queue.enqueue(this, msg, pkt, &CogStorage::noop_const);
119121}
120122
121123void CogStorage::updateValue(const Handle& h, const Handle& key,
……@@ -127,7 +129,8 @@ void CogStorage::updateValue(const Handle& h, const Handle& key,
127129 Sexpr::encode_atom(key) +
128130 Sexpr::encode_value(delta) + ")\n";
129131
130 _io_queue.enqueue_noreply(msg);
132 Pkt pkt;
133 _io_queue.enqueue(this, msg, pkt, &CogStorage::noop_const);
131134}
132135
133136void CogStorage::loadValue(const Handle& h, const Handle& key)