Feature/issue 358 idle state

Fix for #358  - Invalid state of Push replicator between IDLE and RUNNING under continuous mode


Solutions
1. Add state-machine trigger from IDLE to RUNNING
2. Extends LinkedBlockingQueue to support queue event listener
3. Call waitForPendingFuture() method and switch state from IDLE to RUNNING if necessary whenever Future task is added into pending queue.
4.  Switch state from RUNNING to IDLE if necessary at end of waitForPendingFuture() method
calling  fireTrigger(ReplicationTrigger.RESUME) when the state is not IDLE, it causes IllegalStateException in fireTrigger() method. But, as fireTrigger uses workExecutor and catches exception, so it does not causes the problem. Which way do you prefer?

12-19 12:15:03.707    7342-7362/com.couchbase.lite.test W/Sync﹕ [fireTrigger()] => RESUME
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test D/Sync﹕ firing trigger: RESUME
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test W/System.err﹕ java.lang.IllegalStateException: No valid leaving transitions are permitted from state 'RUNNING' for trigger 'RESUME'. Consider ignoring the trigger.
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test W/System.err﹕ at com.github.oxo42.stateless4j.StateMachine$1.doIt(StateMachine.java:37)
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test W/System.err﹕ at com.github.oxo42.stateless4j.StateMachine.publicFire(StateMachine.java:188)
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test W/System.err﹕ at com.github.oxo42.stateless4j.StateMachine.fire(StateMachine.java:126)
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test W/System.err﹕ at com.couchbase.lite.replicator.ReplicationInternal$1.run(ReplicationInternal.java:188)
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test W/System.err﹕ at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test W/System.err﹕ at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test W/System.err﹕ at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
12-19 12:15:03.707    7342-7361/com.couchbase.lite.test W/System.err﹕ at java.lang.Thread.run(Thread.java:841)