Skip to main content
0 votes
0 answers
134 views

Consider this example: #include <atomic> #include <chrono> #include <thread> int main() { std::atomic<long int> key; auto t1 = std::thread([&]() { auto now =...
xmh0511's user avatar
  • 7,675
1 vote
0 answers
184 views

Consider this example: #include <thread> #include <atomic> #include <stream> int main(){ std::ofstream outFile("example.txt", std::ios::out | std::ios::trunc); std::...
xmh0511's user avatar
  • 7,675
-1 votes
0 answers
135 views

Consider this example: #include <thread> #include <atomic> extern char* mysql_query(MYSQL* mysql,char const*); extern char* do_mysql_update(MYSQL* mysql); int main(){ std::atomic<bool&...
xmh0511's user avatar
  • 7,675
7 votes
1 answer
271 views

Let's say I call a memory barrier like: std::atomic_thread_fence(std::memory_order_seq_cst); From the documentation I read that this implement strong ordering among all cores, even for non atomic ...
Mascarpone's user avatar
  • 2,666
1 vote
1 answer
253 views

Consider this example: #include <atomic> #include <iostream> #include <thread> std::atomic<int> canceller = {0}; int main() { auto t1 = std::thread([]() { auto v = ...
xmh0511's user avatar
  • 7,675
3 votes
0 answers
168 views

Consider this example: #include <atomic> #include <iostream> #include <thread> std::atomic<int> canceller = {0}; int main() { auto t1 = std::thread([]() { auto v = ...
xmh0511's user avatar
  • 7,675
1 vote
1 answer
175 views

Consider this example: #include <thread> #include <atomic> int main(){ std::atomic<int> x = 0, y = 0; auto t1 = std::thread([&](){ if(x.load(std::memory_order::relaxed)==...
xmh0511's user avatar
  • 7,675
6 votes
1 answer
164 views

My code is ... fragment1 // compares several regions in D1$ to D1$/D3$ __atomic_fetch_add(&lock,-1,__ATOMIC_ACQ_REL); // stmt A fragment2 // moves several regions from D1$/D3$ to D1$ ...
Henry Rich's user avatar
5 votes
1 answer
389 views

Consider this example: #include <atomic> #include <cassert> #include <thread> int main() { std::atomic<int> strong = {3}; std::atomic<int> weak = {1}; auto t1 ...
xmh0511's user avatar
  • 7,675
2 votes
0 answers
144 views

Consider this example: #include <iostream> #include <atomic> #include <thread> #include <cassert> int main(){ std::atomic<int> val = 1; std::atomic<std::atomic&...
xmh0511's user avatar
  • 7,675
0 votes
2 answers
152 views

I am trying to implement a lock-free multiple-producer-single-consumer ring buffer in C++. Here is the full definition and the test code. #include <iostream> #include <memory> #include <...
God_of_Thunder's user avatar
3 votes
1 answer
160 views

The ECMAScript Language Specification states: Atomics are carved in stone: Program transformations must not cause any Shared Data Block events whose [[Order]] is seq-cst to be removed from the is-...
James Page's user avatar
1 vote
2 answers
217 views

Consider this example: #include <iostream> #include <thread> #include <atomic> int main(){ std::atomic<int> val = 0; std::atomic<bool> flag = false; auto t1 = std::...
xmh0511's user avatar
  • 7,675
1 vote
1 answer
201 views

I have a bounded queue with small size that definitely fit in int. So I want to use atomic<int> instead of atomic<size_t> for indexing/counter, since int is smaller it should be faster. ...
Huy Le's user avatar
  • 2,009
0 votes
0 answers
353 views

Consider this example: // thread A: start_transaction(); update_mysql(); commit_transaction(); // remove "key" from mysql tables remove_redis_cache("key"); // thread B: std::...
xmh0511's user avatar
  • 7,675

15 30 50 per page
1
2 3 4 5
271