Skip to content

Instantly share code, notes, and snippets.

@minisu
Last active August 29, 2015 14:00
Show Gist options
  • Save minisu/11179770 to your computer and use it in GitHub Desktop.
Save minisu/11179770 to your computer and use it in GitHub Desktop.
/*
* When a Task is aborted, it should b aborted in the taskQueue and its state should be
* persisted to taskStorage. There is also a start method with similar requirements.
*
* Below are different implementation alternatives for a REST method.
*/
// Alt. 1 -- Task knows about taskStorage and taskQueue:
taskStorage.getTask( id ).abort().save();
// ------------------------
// Alt. 2:
taskStorage.getTask( id ).abort();
taskStorage.save( t );
taskQueue.abort( e );
// ------------------------
// Alt. 3
taskStorage.abort( id );
taskQueue.abort( id );
// ------------------------
// Alt. 4 -- Task knows about taskQueue. A callback that updates taskStorage
// has been registered using Task.setOnAborted:
taskStorage.getTask( id ).abort();
// ------------------------
// Alt. 5 -- Similar to alt. 4, but Task doesn't know about taskQueue.
taskQueue.abort( id );
// ------------------------
// Alt. 6 -- Aspect Oriented Programming
// This annotation would only be used once in the codebase.
class TaskQueue {
@PersistState
void abort( Task t )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment