![]() * This version demonstrates the extreme configurability of the CouchBase Lite replicator callback system. ListenerToken token = repl.addChangeListener(MAX_THROUGHPUT_EXEC, listener::changed) ![]() ![]() Private static final ExecutorService MAX_THROUGHPUT_EXEC = Executors.newCachedThreadPool() * a processor will be queued as Threads, (instead of as Runnables) with accompanying memory In addition, when notifications swamp the processors, notifications awaiting * In fact, they must be re-entrant because a given listener may be running on mutiple threads * Listeners must be thread safe because they may be called from multiple threads. It may deliver change notifications out of order. It will deliver change notifications as quickly ListenerToken token = repl.addChangeListener(IN_ORDER_EXEC, listener::changed) Replicator repl = new Replicator(config) ReplicatorConfiguration config = new ReplicatorConfiguration(db1, new DatabaseEndpoint(db2)) ĬtReplicatorType(_AND_PULL) Public Replicator runReplicator(Database db1, Database db2, ReplicatorChangeListener listener) Private static final ExecutorService IN_ORDER_EXEC = Executors.newSingleThreadExecutor() * depending on how long it takes the listener to run. Events may be delivered arbitrarily late, though, * It will run on only thread (the Executor's thread) and must return from a given call * The listener does not need to be thread safe (at least as far as this code is concerned). * This version guarantees in order delivery and is parsimonious with space
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |