New answers tagged

3

In C# you can use ReaderWriteLock class to allow a single write operation in your file (and multiple readers, if this is needed). Also, to maximize performance you can have asynchronous operations using Asynchronous File I/O (you can have some processing while the I/O operations are being done). However, before diving into these concepts, some things must ...


0

Not a strict unit test, but a runtime check that has helped me with some intermittently failing tests. It's quick & dirty, but it worked. When a mutex is granted I keep a track of which thread has it. All mutex requests have a thirty-second timeout, after which they scream deadlock. I can then use the list of granted mutexes to see which thread is ...


0

From the code it looks like it should work. Spinning off queued threads to the thread pool from an event listener should not cause issues (and I use a similar pattern is some of my code). You will want to stress test the code to make sure that through put is enough to keep up and I would read up on error handling in multi threaded code ...


3

It is not generally sensible to limit the number of threads, if these threads are used only for concurrency. I.e. aside from the extra resource use, spawning threads is fine to manage blocking operations, increase responsiveness, …. A good example is a web crawler that might want to download multiple small resources, and uses multiple threads to compensate ...


9

I've studied The Art of Multiprocessor Programming1 and their text is lacking in clarity, just like the book you refer to. Here are some quotes from TAMPP: Quote 1 (Definition of lock-free) A method is lock-free if it guarantees that infinitely often some method call finishes in a finite number of steps. Quote 2 (Definition of nonblocking) a ...


0

I think that using threads for this is an overkill, especially since (I'm assuming) those threads will stay idle most of the time. Instead, what you can do is to use async-await to be more efficient. If you really need to run the code on a separate thread from the current one, you can use Task.Run() for that. To control whether the code is enabled or not, ...


0

I think this is strictly an OGL question, and the solution doesn't have to be so hard. I've dealt with this issue many times before, encountering the same issues years before when I first tried to wrap OGL resources into object-oriented designs -- and got burnt both ways, not just trying to destroy resources outside of a valid GL context, but also trying to ...


0

Consider software that controls a complex instrument. Periodically it polls the instrument to read a bunch of values: voltages, pressures, percent complete, warning flags, etc. Imagine that the data comes down as XML/JSON, or maybe some binary form, over USB or Ethernet. This data is displayed in a modeless dialog for the user to monitor. That dialog may ...


1

Micro-Facets of Functionality This is going to be more of a general design strategy answer, without understanding the precise issues you are dealing with in a networking context. It might completely miss. Yet understanding this was so helpful to me in just software engineering in general that I'm eager to share it, and I think it has a good chance of ...


1

The presentation domain data model is concerned with rendering the application domain data model on the screen. For example, let's say you have a table in your application data model, and want to present that data, filtered and/or sorted as the user chooses. In that case, the choice of filter and/or sort is an aspect of the presentation domain. (The ...


0

The idea here is to incrementally change things using events instead of refreshing the model every time the user needs the "latest data". Suppose for example an application that shows the contents of a database table, for example, in a select box. Usually, when you refresh the component, the app queries the whole database table and update the whole list, ...



Top 50 recent answers are included