This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Runnable getTask() { | |
boolean timedOut = false; // Did the last poll() time out? | |
for (;;) { | |
int c = ctl.get(); | |
int rs = runStateOf(c); | |
// return null to terminate Worker | |
// when there's no more task in the work queue | |
// Check if queue empty only if necessary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final class ProxyClassFactory | |
implements BiFunction<ClassLoader, Class<?>[], Class<?>> | |
{ | |
// prefix for all proxy class names | |
private static final String proxyClassNamePrefix = "$Proxy"; | |
// next number to use for generation of unique proxy class names | |
private static final AtomicLong nextUniqueNumber = new AtomicLong(); | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException | |
{ | |
// obtain the lock for the class name, | |
// or lock on the ClassLoader instance if the ClassLoader is not parallel-capable | |
synchronized (getClassLoadingLock(name)) { | |
// First, check if the class has already been loaded | |
Class<?> c = findLoadedClass(name); | |
if (c == null) { | |
long t0 = System.nanoTime(); | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final void runWorker(Worker w) { | |
// current thread will be the Worker's thread | |
// since this method will be called in Worker#run() | |
// and Worker instance implements Runnable, and is associated with its own thread | |
Thread wt = Thread.currentThread(); | |
Runnable task = w.firstTask; | |
w.firstTask = null; | |
w.unlock(); // allow interrupts | |
boolean completedAbruptly = true; | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean addWorker(Runnable firstTask, boolean core) { | |
retry: | |
for (;;) { | |
int c = ctl.get(); | |
int rs = runStateOf(c); | |
// Check if queue empty only if necessary. | |
if (rs >= SHUTDOWN && | |
! (rs == SHUTDOWN && | |
firstTask == null && |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void execute(Runnable command) { | |
if (command == null) | |
throw new NullPointerException(); | |
/* | |
* Proceed in 3 steps: | |
* | |
* 1. If fewer than corePoolSize threads are running, try to | |
* start a new thread with the given command as its first | |
* task. The call to addWorker atomically checks runState and | |
* workerCount, and so prevents false alarms that would add |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sendMessage(msg: Envelope): Unit = | |
try { | |
val msgToDispatch = | |
if (system.settings.SerializeAllMessages) serializeAndDeserialize(msg) | |
else msg | |
dispatcher.dispatch(this, msgToDispatch) | |
} catch handleException | |
// Dispatcher.dispatch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Process the messages in the mailbox | |
*/ | |
@tailrec private final def processMailbox( | |
left: Int = java.lang.Math.max(dispatcher.throughput, 1), | |
deadlineNs: Long = if (dispatcher.isThroughputDeadlineTimeDefined == true) System.nanoTime + dispatcher.throughputDeadlineTime.toNanos else 0L): Unit = | |
if (shouldProcessMessage) { | |
val next = dequeue() // get first message in the queue | |
if (next ne null) { | |
if (Mailbox.debug) println(actor.self + " processing message " + next) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private[akka] abstract class Mailbox(val messageQueue: MessageQueue) | |
extends ForkJoinTask[Unit] with SystemMessageQueue with Runnable { | |
// code omitted | |
override final def run(): Unit = { | |
try { | |
if (!isClosed) { //Volatile read, needed here | |
processAllSystemMessages() //First, deal with any system messages | |
processMailbox() //Then deal with messages |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* LocalActorRef.start | |
* Starts the actor after initialization. | |
*/ | |
override def start(): Unit = actorCell.start() | |
/** | |
* dungeon.Dispatch.start | |
* Start this cell, i.e. attach it to the dispatcher. | |
*/ |
NewerOlder