Say I have this method:
def create_registration_unless_over_limit
if Registration.count < 50
Registration.create!
else
raise "too many registrations"
end
end
How do I ensure that I never have >= 50 registrations considering that I have more than one rails process running? Theoretically, isn't it possible that two reques...
I was thinking of using StructureMap's profiles to facilitate offering up slight differences in behavior in my web app based on the authenticated user's type. My question is, if I do something like
ObjectFactory.Profile = Session["UserType"];
is it going to be thread-safe or will simultaneous requests potentially interfere with each o...
Hello,
I'm wondering if there is a boost equivalent of ManualResetEvent? Basically, I'd like a cross-platform implementation... Or, could someone help me mimic ManualResetEvent's functionality using Boost::thread? Thanks guys
...
Basically I want something like Dictionary<Tkey1, TKey2, TValue>, but not (as I've seen here in other question) with the keys in AND, but in OR. To better explain: I want to be able to find an element in the dictionary providing just one of the keys, not both.
I also think we should consider thread-safety and the ability to easily scale...
My application composes a webpage model from a number of xml sources. These sources are being parsed into memory as DOM objects with the normal Xerces parser. Unfortunately, Xerces DOM objects are not thread safe for read-only operations. I would like to be able to reuse the parsed DOM for read. Does anyone know of another parser or ...
I am working with a system that uses GUIDs as keys in most database tables. The guids are created using UuidCreateSequential, in order to be nice to the database indexes.
C++ syntax, according to http://msdn.microsoft.com/en-us/library/aa379322%28VS.85%29.aspx :
RPC_STATUS RPC_ENTRY UuidCreateSequential(
UUID __RPC_FAR *Uuid
);
p...
Can i call executeBacth from a thread while another one keeps calling addBatch() on the same Statement ( or PreparedStatement ) object?
Update: Does anyone have exprerience with this issue? 'cause i get incorrect results. Not all updates i added to the the batch is executed.
...
Let's say I have
class classA {
void someMethod()
{
Thread a = new Thread(threadMethod);
Thread b = new Thread(threadMethod);
a.Start();
b.Start();
a.Join();
b.Join();
}
void threadMethod()
{
int a = 0;
a++;
Console.Writeline(a);
}
}
class classB {
void someMethod()
...
I've written a Blackberry appliation with the Blackberry JDE, running on a 9000 simulator. I tested it a week or so ago and loaded it on a Blackberry 9000 phone, and everything worked just fine. Sometime between then and now, though, something went wrong.
My code does the whole moving arrow "loading things from the internet" or whatever...
I'm writing a class for logging events. My LogClass is implemented as a singleton, and any class in the system can write a log entry. The entries are stored in a List and when a buffer is filled they get dumped to the disk.
I'm using a DataGridView to display the contents of the LogClass during execution, therefore I used the BindingLis...
We're trying to build a class that provides the MFC CRecordset (or, really, the CODBCRecordset class) thread safety. Everything actually seem to work out pretty well for the various functions like opening and moving through the recordset (we enclose these calls with critical sections), however, one problem remains, a problem that seems t...
In my WPF app I have a long running upload running, which raises progress events as it goes which updates a progress bar. The user also has a chance of cancelling the upload, or it might go wrong. These are all async events, so they need to be executed using Dispatcher.Invoke in order to update the UI.
So the code looks like this, ish:
...
To rephrase the question: should I avoid sharing instances of classes which implement java.sql.Connection between different threads?
...
So this is a very particular question:
I use an embedded system with a single CPU core.
I have one main thread and an interrupt. They share a 32-bit float. The interrupt writes the float, and the main thread reads it. Reads and writes are not synchronized.
The processor documentation states that the 32-bit read is a one-cycle operatio...
The following code is thread-safe as far as I can tell, with the caveat that I am not looking for a singleton pattern (I don't care if multiple threads get different instances of MyObject as MyObject is immutable. After the potential contention among the concurrent threads that create multiple instances, subsequent threads will all get ...
What initially seemed like a problem with an easy solution has proven to be quite an interesting challenge.
I have a class which maintains an internally fixed-size, thread-safe collection (by way of using lock on all insertion and removal operations) and provides various statistical values via its properties.
One example:
public doubl...
Following thread code runs 2058 times, after that it crashes. Can somebody help me figure out why? The idea of the program is create some class in main thread, pass it to worker thread, thread fills needed data and pass data back to main thread. This example crashes after 2058 runs, however it should go indefinately. I've run it 20 times...
I have a number of classes that represents business transaction calls: executing appropriate stored procedures.
Now the looks like this:
public static class Request
{
public static void Approve(..) {
using(connection) {
command.Text = "EXEC [Approve] ,,"]
command.ExecuteNonQuery();
}
}
}
...
I'm using ThreadSafeClientConnManager to manage a pool of client connections, because my application has several threads, which are simultaneously connecting to a webserver.
Abstract sample code:
HttpClient httpClient;
ClientConnectionManager conMgr = new ThreadSafeClientConnManager(parameters,schReg);
httpclient = new DefaultHttpClie...
I see this idiom of initializing instance variables quite a bit
public class Test{
private Long l = 1l;
private MyClass mc = new MyClass();
public Test(){}
...
}
But I would prefer
public class Test{
private Long l;
private MyClass mc;
public Test(){
l = 1l;
mc = new MyClass();
}
...