concurrency

How to optimize callbacks from a NSOperationQueue-started thread

Consider this: @interface SomeViewController : UIViewController { SomeChildObject *child; } @end @implementation SomeViewController - (void) viewDidLoad { ... child.delegate = self; } - (void) somethingHappened { NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:child sel...

usability of synchronized... methods in java.util.Collections

I'm looking at the static method Collections.synchronizedList(List<T> list) Javadoc says It is imperative that the user manually synchronize on the returned list when iterating over it... What's the purpose of creating a synchronized list if I still have to manually synchronize it? ...

What is the story with shared data synchronization using the MS AJAX 4.0 client library?

Consider a LOB site, where users work on a large shared dataset. Using Wcf Data Services on the server side and the DataContext and DataView from the AJAX 4.0 client library on the client side to enable CRUD operations. Getting the data on the initial load is straight forward, just query the server and display the data (in a table for e...

Calling a WCF service contract from inside a callback implementation

Hi, I 'm having a problem with WCF callbacks that's a proper head-scratcher... Description of setup: There's an interface IService that defines a WCF service. My server app implements that service in class ServiceImplementation. The service also has a callback, defined in IServiceCallback and implemented in the client app in class Call...

How would one setup autotools to build a project for separate architectures, concurrently, on multiple systems?

I've got a C++ project which uses automake and autoconf. I'm new to both of these. My home directory is network mounted -- the same on every server we have -- and I want to compile and run the project (and its executable) concurrently on separate machines. Our servers are frequently different architectures. My desktop is 32-bit, but th...

Difficult concurrent design

I have a class called Root which serves as some kind of phonebook for dynamic method calls: it holds a dictionary of url keys pointing to objects. When a command wants to execute a given method it calls a Root instance with an url and some parameter: root_->call("/some/url", ...); Actually, the call method in Root looks close to this:...

SELECT and UPDATE table so there is no overlap of Threads

Hi, Say I have the following table: ID|Read ------- 1|true 2|false 3|false 4|false ... and I need to read the smallest ID, that has [Read] == false; plus, update that I have now read it. So if i execute my Stored Procedure dbo.getMinID, it will return ID: 2, and update [Read] -> true. CREATE PROCEDURE [dbo].[getMinID] ( @Quer...

Joining ajax results?

I need to generate a result from 2 XMLHttpRequests. How can I make the requests concurrently and wait for them to both finish? I've though of something like... resp1=""; req1.onreadystatechange=function(){if(this.readyState=4)resp1==this.responseText;} req2.onreadystatechangefunction(){if(this.readyState=4) finish(this.responseText);} ...

Statement reordering with locks

Here some C++ code that is accessed from multiple threads in parallel. It has a critical section: lock.Acquire(); current_id = shared_id; // small amounts of other code shared_id = (shared_id + 1) % max_id; lock.Release(); // do something with current_id The class of the lock variable is wrapper around the POSIX mutex implementation. ...

design patterns for concurrent programming???

hi has anyone implemented design patterns for concurrent programming. If so did you have any implementation issues/difficulties?? Thanks ~Sanjay ...

concurrent reference counter class and scoped retain: is this ok ?

This is a question regarding coding design, so please forgive the long code listings: I could not resume these ideas and the potential pitfalls without showing the actual code. I am writing a ConcurrentReferenceCounted class and would appreciate some feedback on my implementation. Sub-classes from this class will receive "release" inste...

Java locking of elements inside array

Hello I have dynamic array of hashtables Can I use synchronized for each of them separately? Like synchronized(array[1]) { code .. }, synchronized(array[2]) { code .. } Thanks ...

winforms concurrency question

Hi, What approach(es) would you recommend regarding a WinForms application that will have both the user interface & a scheduling components regarding sharing configuration data from the database? (exposed in the program via DataTable) Assume both the scheduled task and the user interface can make updates to the shared data. Also ass...

Recommended language for writing a web service

I am an open source developer, and I need to write a highly-scalable web service. For a variety of reasons (basically poor support for concurrency), I am using Ruby on Rails for my app front-end but not for the back-end (read: http://www.ddj.com/go-parallel/article/showArticle.jhtml?articleID=212903282). My web service will need to call ...

Asynchronous HTTP request

require 'net/http' urls = [ {'link' => 'http://www.google.com/'}, {'link' => 'http://www.yandex.ru/'}, {'link' => 'http://www.baidu.com/'} ] urls.each do |u| u['content'] = Net::HTTP.get( URI.parse(u['link']) ) end print urls This code works in synchronous style. First request, second, third. I would like to send all requests...

How to create a ReadWriteMutex without specifying the semaphore's resource count ?

The usual pattern for a ReadWriteMutex is to use a semaphore and have the writer loop to acquire all the resources: inline void write_lock() { ScopedLock lock(acquire_mutex_); for (size_t i=0; i < resource_count_; ++i) { if (sem_wait(semaphore_) < 0) { fprintf(stderr, "Could not acquire semaphore (%s)\n", strerror(errno));...

fork() and printf()

As I understood fork() creates a child process by copying the image of the parent process. My question is about how do child and parent processes share the stdout stream? Can printf() function of one process be interrupted by other or not? Which may cause the mixed output. Or is the printf() function output atomic? For example: The...

how to handle concurrency in java servlets

Hello , In my doPost method of the servlet I need to access a file (shared resource ) and update the file . How do I cater to some 100 users using this at the same time ? Regards, Mithun ...

Are BSD/Posix sockets reentrant?

Can several threads operate on the same socket descriptor, i.e accept(sock_fd) at the same time without concern? The platform I'm mostly interested in is POSIX/Linux. ...

Is update with nested select atomic operation?

I need to select first (let's say) 10000 rows in database and return them. There may be more clients that do this operation at one time. I came up with this query: update v set v.batch_Id = :batchId from tblRedir v inner join ( select top 10000 id from tblRedir where batch_Id is null ...