C# Singleton Pattern Designs for ThreadStatic

I want to figure out about singleton pattern designs. I want to create seperated instances for per thread from my singleton class. So I provided two designs below. It is Working class Program { static void Main(string[] args) { Task...
more »

2017-11-11 15:11 (2) Answers

CoreText crashed when run in multiple threads

Crashed when I calculate layout in multiple threads . I've looked up the answers but there are mostly out of date . They said that there is Apple's CoreText bug , and has been fixed . But crashed models include iPhone6、iPhone6s、iPhone7、iPhone8
more »

2017-11-09 07:11 (0) Answers

SpriteKit, put a process on another core?

Imagine in your class NattyScene: SKScene { you have perhaps a custom Field for the nodes, or something else that happens every frame. Now imagine you have some calculation, a nice example might be center of gravity ... var globalCOG: CGPoint fu...
more »

2017-11-09 00:11 (1) Answers

Invoking a method's result to the main thread

I am wondering about the following: I have an observable collection named Container and method named Method. On the main thread I want to add the returned value from Method to the Container. The following code runs on another thread, so I have to ...
more »

2017-11-03 08:11 (2) Answers

Happens-before for direct ByteBuffer

I have a direct ByteBuffer (off-heap) in one thread and safely publish it to a different thread using one of the mechanisms given to me by JMM. Does the happens-before relationship extend to the native (off-heap) memory wrapped by the ByteBuffer? If ...
more »

2017-11-01 09:11 (2) Answers

Node.js clustering vs multiple Docker containers

From what I understand, Docker containers use multiple threads, and Node.js applications use only a single thread. By running something like pm2, which handles Node.js clustering, I could utilize all cores available to the Docker container. Would th...
more »

2017-10-30 08:10 (3) Answers

Why is My Async Timer Blocking the UI Thread?

I have a timer setup in my mainwindow code behind that fires every ten seconds. Because some of the code referenced in the timer_Elapsed event is somewhat CPU intensive I have placed it inside an await Task.Run(() =>, however the UI thread continu...
more »

2017-10-29 02:10 (1) Answers

WPF TextBox performance

I am developing an application which retrieves data in a separate thread. A delegate is 'called' within the thread to get the data in a viewmodel. A string property will be used to set the text of a WPF TextBox (databinding). ViewModel private stri...
more »

2017-10-23 20:10 (1) Answers

How to lock objects withthe same ids?

I have got the following code: public void Update(Foo foo) { lock(_locker) { UpdateFirstPart(foo.First); UpdateSecondPart(foo.Second); UpdateThirdPart(foo.Third); } } public class Foo { public int Id; ...
more »

2017-10-23 13:10 (3) Answers

Atomically modify int value

Googling for ABA-problem that may appear when using CompareAndSwap-like Read-Modify-Write instruction set I found Load-Linked/Store-Conditional lock-free approach to that problem. So, I tried to implement LL/SC for ints using just CAS-set of instru...
more »

2017-10-21 23:10 (0) Answers

Changing thread context in C# console application

I have a C# console app in which I can get, among other things, input via a TCP socket connection. How do I switch to the main thread when I receive an input via the receive function over the socket? So similar to something like this in WPF: public...
more »

2017-10-21 12:10 (1) Answers

Can fread be non rentrant?

In a program written in C++ and compiled with MinGW-w64 under windows, I read several files concurrently in separate threads. Since the file names may have non ASCII characters, I cannot use the C++ standard library std::ifstream as it does not suppo...
more »

2017-10-18 23:10 (1) Answers

Perl: JSON fails if a thread is started

Can someone please tell my why JSON is not working if some thread is started? use strict; use warnings; use JSON; use threads; use threads::shared; sub th { } threads->create(\&th)->join() if $ARGV[0]; my $json = to_json({ val => "...
more »

2017-10-17 17:10 (2) Answers

Receiving raw ethernet packets - timing issues

I have a scenario where I construct and send a raw ethernet packet to a bespoke hardware device. The packet triggers a response packet to be sent back by the device. My code performs a sendto() call to transmit the outgoing packet and after that a r...
more »

2017-10-05 14:10 (0) Answers