I hereby claim:
- I am lwahlmeier on github.
- I am howdyboby (https://keybase.io/howdyboby) on keybase.
- I have a public key ASCgkl68TBFlQ5G4IloOLPnX6od6M6v1Pfq1qFHOZaG5OAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
@Test | |
public void test111() throws InterruptedException, ExecutionException { | |
HTTPClient client = new HTTPClient(1, 1000000,SEI); | |
List<ListenableFuture<HTTPResponseData>> lf = new ArrayList<>(); | |
for(int i=0; i<1000; i++) { | |
ListenableFuture<HTTPResponseData> hl = client.requestAsync(new HTTPRequestBuilder().setPath("/index.html").setHost("localhost").setPort(80).buildClientHTTPRequest()); | |
lf.add(hl); | |
} |
/** | |
* <p>Whenever a the {@link Reader} Interfaces {@link Reader#onRead(Client)} is called the | |
* {@link #getRead()} should be called from the client.</p> | |
* | |
* @return a {@link ReuseableMergedByteBuffers} of the current read data for this client. | |
*/ | |
public ReuseableMergedByteBuffers getRead() { | |
final SettableListenableFuture<ReuseableMergedByteBuffers> slf = new SettableListenableFuture<>(); | |
this.clientExecutor.submit(()->slf.setResult(this.getInternalRead())); | |
try { |
protected void callReader(boolean onClientThread) { | |
final Runnable localReaderCaller = this.readerCaller; | |
if (readerCaller != null) { | |
if (onClientThread) { | |
readerCaller.run(); | |
} else { | |
getClientsThreadExecutor().execute(()->{ | |
if(localReaderCaller == readerCaller) { | |
readerCaller.run(); | |
} |
protected void runListener(Executor executor, boolean throwException, Runnable ...listener) { | |
try { | |
if (executor != null) { | |
executor.execute(()->{ | |
for(Runnable r: listener) { | |
r.run(); | |
} | |
}); | |
} else { | |
for(Runnable r: listener) { |
public TaskWrapper getNextTask() { | |
// First compare between high and low priority task queues | |
// then depending on that state, we may check starvable | |
TaskWrapper nextTask = null; | |
if (lowPriorityQueueSet.isEmpty() && !highPriorityQueueSet.isEmpty()) { | |
nextTask = highPriorityQueueSet.getNextTask(); | |
} else if (!lowPriorityQueueSet.isEmpty() && !highPriorityQueueSet.isEmpty()) { | |
if(highPriorityQueueSet.timeSinceLastPull() > maxWaitForLowPriorityInMs) { | |
nextTask = lowPriorityQueueSet.getNextTask(); |
public TaskWrapper getNextTask() { | |
TaskWrapper schTask = null; | |
if(!scheduleQueue.isEmpty() && !checkingScheduled.get() && checkingScheduled.compareAndSet(false, true)) { | |
while((schTask = scheduleQueue.peekFirst()) != null && schTask.getScheduleDelay() <= 0) { | |
if(schTask.canExecute(schTask.getExecuteReference())) { | |
scheduleQueue.remove(schTask); | |
executeQueue.add(schTask); | |
} | |
} |
package org.threadly.util; | |
import java.util.concurrent.atomic.AtomicInteger; | |
import org.threadly.concurrent.PriorityScheduler; | |
import org.threadly.concurrent.SubmitterScheduler; | |
import org.threadly.concurrent.wrapper.KeyDistributedScheduler; | |
import org.threadly.concurrent.wrapper.limiter.SubmitterSchedulerLimiter; | |
public class CenteralThreadManager { | |