I have the following situation:
The tasks are triggered this way:
How can I enforce this chain of events?
One way would be to perform Task A and B at the beginning of Task C, but the user event triggering Task C might never happen, but Task A and B must be performed nevertheless.
In a "normal" program I'd have the whole arsenal of synchronization objects at my disposal (mutexes, semaphores, critical sections, ...). But what can I do here?
(If it matters, the Rails application will run on a Linux server and Workling is set up to use Starling)
You can use a distributed lock:
http://github.com/tanin47/ruby_redis_lock (which is mine)
It requires Redis, though.
Or, you can build a lock library by yourself with other dbms, e.g. MySQL.