4 ms·
Fair enough! I'd be interested if Github Copilot can take this as a prompt and spit out C/C++ for it...
by gavinray 4y ago
Fair enough! I'd be interested if Github Copilot can take this as a prompt and spit out C/C++ for it...
- gavinray 4y agoThis is what it spit out, if anyone is curious (best of them, from what I could tell, I dunno much about concurrent programming but this looked the most reasonable to me): I started by typing this: template <typename T> struct uint64_compressed_ptr_and_counter This is one of the implementations it generated: https://godbolt.org/z/hbfY6GPzo https://godbolt.org/z/hbfY6GPzo I don't think this is correct since it doesn't use CAS/atomics but it's certainly interesting. Comments that it generated for the classes: // This is a lock-free stack that uses pointer compression to store a counter // and a tag in the pointer. The tag is used to indicate whether the stack is // empty or not, and the counter is used to detect ABA problems. template <typename T> class uint64_compressed_ptr_and_counter_stack
- pclmulqdq 4y agoThat's funny - it's far from correct, but it looks like a lot of lock free data structures in an aesthetic sense.