I understand the basics of dataflow programming and have encountered it a bit in Clojure APIs, talks from Jonas Boner, GPars in Groovy, etc. I know it's prevalent in languages like Io (although I have not studied Io).
What I am missing is a compelling reason to care about dataflow as a paradigm when building a concurrent program. Wh...
I would like to use the new concurrent collections in .NET 4.0 to solve the following problem.
The basic data structure I want to have is a producer consumer queue, there will be a single consumer and multiple producers.
There are items of type A,B,C,D,E that will be added to this queue. Items of type A,B,C are added to the queue in th...
hi all, I have 2 pools of threads
ioThreads = (ThreadPoolExecutor)Executors.newCachedThreadPool();
cpuThreads = (ThreadPoolExecutor)Executors.newFixedThreadPool(numCpus);
I have a simple web crawler that I want to create an iothread, pass it a url, it will then fetch the url and pass the contents over to a cpuThread to be processed ...
I've taken a look into OpenJDK's sources of CopyOnWriteArrayList and it seems that all write operations are protected by the same lock and read operations are not protected at all. As I understand, under JMM all accesses to a variable (both read and write) should be protected by lock or reordering effects may occur.
For example, set(int...
When communicating concurrency conflicts to your application layer, is there an alternative to using exceptions that also respects the principle of Command-Query Separation, or are exceptions the best mechanism we have (in languages that support exceptions)?
In the bowels of my application, I have optimistic locking logic that executes ...
Consider the following scenario. We have a C++ function with a static local variable:
void function()
{
static int variable = obtain();
//blahblablah
}
the function needs to be called from multiple threads concurrently, so we add a critical section to avoid concurrent access to the static local:
void functionThreadSafe()
{
...
This question made me question a practice I had been following for years.
For thread-safe initialization of function-local static const objects I protect the actual construction of the object, but not the initialization of the function-local reference referring to it. Something like this:
namspace {
const some_type& create_const_th...
I am trying to write 2 server/client programs under Linux, in which they communicate through named pipes. The problem is that sometimes when I try to write from the server into a pipe that doesn't exist anymore (the client has stopped), I get a "Resource temporarily unavailable" error and the server stops completely.
I understand that ...
Hi there:
I come up with this question when implementing singleton pattern in Java. Even though the example listed below is not my real code, yet very similar to the original one.
public class ConnectionFactory{
private static ConnectionFactory instance;
public static synchronized ConnectionFactory getInstance(){
if( i...
I have a Silverlight 4 project using WCF RIA Services RTM. Most of the RIA functionality is working, but I'm having a problem with concurrency checking. The server is correctly checking concurrency and passing a DomainOperationException to the DomainDataSource.SubmittedChanges event. I'm handling that even and enumerating the Entities...
I have been playing with my own version of this, using 'if', and all seems to be working fine. Of course this will break down horribly if signalAll() is used instead of signal(), but if only one thread at a time is notified, how can this go wrong?
Their code here - check out the put() and take() methods; a simpler and more-to-the-point...
Hello Experts,
is
final Map<Integer,Map<String,Integer>> status = new ConcurrentHashMap<Integer, Map<String,Integer>>();
Map<Integer,Map<String,Integer>> statusInner = new ConcurrentHashMap<Integer, Map<String,Integer>>();
status.put(key,statusInner);
the same as
volatile Map<Integer,Map<String,Integer>> status = new ConcurrentHash...
I have done some research on the optimistic concurrency of entity framework and how to ensure that concurrency is dealth with. Mostly it seems that you have to set concurrencyMode=fixed on certain fields in a table, or to keep a detached object of the object being changed.
However, we make use of a once off call method that makes use of...
For the sake of argument, let's say I'm implementing Future for a task which is not cancelable. The Java 6 API doc says:
After [cancel()] returns, subsequent calls to isDone() will always return true.
[cancel()] returns false if the task could not be cancelled, typically because it has already completed normally
It also says:...
I recognize this may be a duplicate post, but I want to make sure I ask this question clearly and get an answer based on my wording.
I have a collection of forms which inherit from a common visual element: MainVisualForm. This element provides me a way to know when the form is advancing of stepping backwards. What form comes next in th...
An example: a permit must be examined by two lawyers and one engineer. If any of those three reject it, the process enters a "rejected" end state. If all three grant the permit, it enters a "granted" end state. All three examiners may examine simultaneously, or in any order.
Once one engineer has granted it, it shouldn't be available t...
I use an ArrayBlockingQueue in my code. Clients will wait untill an element becomes available:
myBlockingQueue.take();
How can I "shutdown" my service in case no elements are present in the queue and the take() ist wating indefenitely for an element to become available? This method throws an InterruptedException. My question is, how c...
I have two threads in haskell that perform IO. (They print only). Something like the following:
thread1 :: IO ()
thread1 = putStrLn "One"
thread2 :: IO ()
thread2 = putStrLn "Two"
I am currently getting results like the following:
OnTwoe
OTnweo
How can I ensure that each thread completes its IO atomically?
...
I'm working on a library which implements the actor model on top of Grand Central Dispatch (specifically the C level API libdispatch). Basically a brief overview of my system is as such:
Communication happens between actors using messages
Multicast communication only (one actor to many actors)
Senders and receivers are decoupled from o...
I am trying to (simply) make a blocking thread queue, where when a task is submitted the method waits until its finished executing. The hard part though is the wait.
Here's my 12:30 AM code that I think is overkill:
public void sendMsg(final BotMessage msg) {
try {
Future task;
synchronized(msgQueue) {
t...