Lock-free Progress Guarantees in a circular buffer queue

This queue data structure is not strictly lock-free by what I consider the most reasonable definition. That definition is something like: A structure is lock-free if only if any thread can be indefinitely suspended at any point while still leaving the structure usable by the remaining threads. Of course this implies a suitable definition of … Read more

SWIFT TASK CONTINUATION MISUSE: leaked its continuation – for delegate?

This message appears if a continuation you created via withCheckedContinuation, or withCheckedThrowingContinuation doesn’t report success or failure before being discarded. This is will lead to resource leaking: Resuming from a continuation more than once is undefined behavior. Never resuming leaves the task in a suspended state indefinitely, and leaks any associated resources. CheckedContinuation logs a … Read more

Recommend a good resource for approaches to concurrent programming? [closed]

I recommend An Introduction to Parallel Programming by Pacheco. It’s clearly written, and a good intro to parallel programming. If you don’t care about something being tied to a language, then Java Concurrency in Practice is a great resource. Oracle’s online tutorial is free, but probably a bit more succinct than what you’re looking for. … Read more

What is the difference between std::shared_ptr and std::atomic aka. std::experimental::atomic_shared_ptr?

The atomic “thing” in shared_ptr is not the shared pointer itself, but the control block it points to. meaning that as long as you don’t mutate the shared_ptr across multiple threads, you are ok. do note that copying a shared_ptr only mutates the control block, and not the shared_ptr itself. std::shared_ptr<int> ptr = std::make_shared<int>(4); for … Read more

No output from goroutine

When your main() function ends, your program ends as well. It does not wait for other goroutines to finish. Quoting from the Go Language Specification: Program Execution: Program execution begins by initializing the main package and then invoking the function main. When that function invocation returns, the program exits. It does not wait for other … Read more

Random access to gzipped files?

Yes, you can access a gzip file randomly by reading the entire thing sequentially once and building an index. See examples/zran.c in the zlib distribution. If you are in control of creating the gzip file, then you can optimize the file for this purpose by building in random access entry points and construct the index … Read more

Dart Future.wait for multiple futures and get back results of different types

In Dart 3, you should use a Record of Futures instead of a List/Iterable so that you can have heterogeneous types. Dart 3 provides wait extensions for such Records that are similar to Future.wait. (See sudormrfbin’s answer for an example.) If you must use Future.wait, you need to adapt each of your Future<T>s to a … Read more

Why reading a volatile and writing to a field member is not scalable in Java?

This is what I think is happening (keep in mind I’m not familiar with HotSpot): 0xf36c9fd0: mov 0x6c(%ecx),%ebp ; vfoo 0xf36c9fd3: test %ebp,%ebp ; vfoo is null? 0xf36c9fd5: je 0xf36c9ff7 ; throw NullPointerException (I guess) 0xf36c9fd7: movl $0x1,0x8(%ebp) ; vfoo.x = 1 0xf36c9fde: mov 0x68(%ecx),%ebp ; sz 0xf36c9fe1: inc %ebx ; i++ 0xf36c9fe2: test %edi,0xf7725000 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)