atomic

Atomic [move to another table, then delete original data]

I have a Data table and an Archive table. A webapp pours data into the Data table, and a cron job pulls the data out every hour and archives it in the Archive table (this keeps the Data table small and quick to work with). As I see it there are two psudo-SQL queries to run: INSERT Archive SELECT * FROM Data; & DELETE FROM Data; H...

Do I need to use locking with integers in c++ threads

The title says it all really. If I am accessing a single integer type (e.g. long, int, bool, etc...) in multiple threads, do I need to use a synchronisation mechanism such as a mutex to lock them. My understanding is that as atomic types, I don't need to lock access to a single thread, but I see a lot of code out there that does use lo...

mpi atomic read/modify/write

hi. Is there an easy way to implement atomic integer operations (one sided) in mpi? last time I looked three years ago, example in mpi book was fairly complex to implement. Thanks ...

PHP rewrite an included file - is this a valid script?

Hi all! I've made this question: http://stackoverflow.com/questions/2921469/php-mutual-exclusion-mutex As said there, I want several sources to send their stats once in a while, and these stats will be showed at the website's main page. My problem is that I want this to be done in an atomic manner, so no update of the stats will overla...

When to use AtomicReference (Java)? Is it really necessary?

I have used AtomicLong many times but I have never needed to use AtomicReference It seems that AtomicReference does either (I copied this code from another stackoverflow question): public synchronized boolean compareAndSet(List<Object> oldValue, List<Object> newValue) { if (this.someList == oldValue) { // someList could be...

Visual C++ 2010 atomic types support?

Does VC++ 2010 have support for C++0x's portable atomic type template? ...

CUDA: accumulate data into a large histogram of floats

I'm trying to think of a way to implement the following algorithm using CUDA: Working on a large volume of voxels, for each voxel I calculate an index i and a value c. after the calculation I need to perform histogram[i] += c c is a float value and the histogram can have up to 15,000 bins. I'm looking for a way to implement this effici...

GCCs atomic builtins - Which processors are supported

This document says: Not all operations are supported by all target processors. Does anybody know, for which processor which operation is supported? ...

AtomicInteger for limited sequnce generation

How can we use AtomicInteger for limited sequence generation say the sequence number has to be between 1 to 60. Once the sequece reaches 60 it has to start again from 1. I wrote this code though not quite sure wether this is thread safe or not? public int getNextValue() { int v; do { v = val.get(); if ( v == 60) { val.se...

atomic swap with CAS (using gcc sync builtins)

Can the compare-and-swap function be used to swap variables atomically? I'm using C/C++ via gcc on x86_64 RedHat Linux, specifically the __sync builtins. Example: int x = 0, y = 1; y = __sync_val_compare_and_swap(&x, x, y); I think this boils down to whether x can change between &x and x; for instance, if &x constitutes an op...

Atomic operations on several transactionless external systems

Say you have an application connecting 3 different external systems. You need to update something in all 3. In case of a failure, you need to roll back the operations. This is not a hard thing to implement, but say operation 3 fails, and when rolling back, the rollback for operation 1 fails! Now the first external system is in an invalid...

e-mail appearing in light blue on atomic browser

Hi, all, I made an html page, and only for Atomic Browser (on iPhone) when I put an e-mail in a page like a "contact us", the e-mail appears in light blue (only in atomic). Anyone have a suggestion for this issue? Regards, Eduardo ...

Updating an atom with a single value

I have a number of atoms in my code where a common requirement is to update them to a new value, regardless of the current value. I therefore find myself writing something like this: (swap! atom-name (fn [_] (identity new-value))) This works but seems pretty ugly and presumably incurs a performance penalty for constructing the anonym...

Using volatile long as an atomic

If I have something like this... volatile long something_global = 0; long some_public_func() { return something_global++; } Would it be reasonable to expect this code to not break (race condition) when accessed with multiple threads? If it's not standard, could it still be done as a reasonable assumption about modern compilers? ...

What is the fastest way to create VB.NET Datatables from SQL TVP

I am in the process of revising code to use TVP to send data from our VB.NET app to the SQL 2008 DB and try to keep all the writes atomic. Using this page as a general guide: http://www.sqlteam.com/article/sql-server-2008-table-valued-parameters I am in the process of creating all the in-code datatables to be sent to the SQL stored pro...

Atomic arithmetic in Rails

I need to perform some atomic arithmetic in Rails but the only way I've found to do it for single objects is via the crude update_all class method, e.g.: Account.update_all(["debits = debits + ?", amount], :id => id) With collection associations, the update_all class method should be usable as an association method, since the collecti...

How to create an atomic function in objective-c

Is there a way to execute a whole objective-c function atomic? As far as I know, using synchronized only protects a specific peace of code from being executed on multiple threads at the same time. But what I want is stop ALL other threads from doing ANYTHING, as long as I execute the function. ...

select the rows affected by an update

How can you get the exact rows affected by an SQL UPDATE statement in MySQL? I have many clients on many computers that can be updating rows in the same table based on WHERE clauses at any time, and each client needs to do something in another system for each row that they affect, so getting the list of affected items must be accurate a...

Atomically get value on Mac OS

I need some function to atomically get int value. Something called OSAtomicGet(). Analog of g_atomic_int_get(). ...

Write an atomic operation

Hi, I would like to execute some methods atomicity with Ruby, according to http://en.wikipedia.org/wiki/Atomicity_(database_systems) For instance, if I have: a = 30 b = 75 I would like to be able to do something like: atomic_operation do a += 10 b -= 39 end Is there a native module in Ruby 1.9 that allow such process? If pos...