Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ import org.slf4j.LoggerFactory
timer
}

protected[this] def mkTimer(): TimerSchedulerCrossDslSupport[T] = new TimerSchedulerImpl[T](this)
protected def mkTimer(): TimerSchedulerCrossDslSupport[T] = new TimerSchedulerImpl[T](this)

override private[pekko] def hasTimer: Boolean = _timer.isDefined

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import pekko.japi.pf.PFBuilder
*/
object Behaviors {

private[this] val _two2same = new JapiFunction2[ActorContext[Any], Any, Behavior[Any]] {
private val _two2same = new JapiFunction2[ActorContext[Any], Any, Behavior[Any]] {
override def apply(context: ActorContext[Any], msg: Any): Behavior[Any] = same
}
private[this] def two2same[T] = _two2same.asInstanceOf[JapiFunction2[ActorContext[T], T, Behavior[T]]]
private def two2same[T] = _two2same.asInstanceOf[JapiFunction2[ActorContext[T], T, Behavior[T]]]

/**
* `setup` is a factory for a behavior. Creation of the behavior instance is deferred until
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ object AskPattern {
private final class PromiseRef[U](target: InternalRecipientRef[?], timeout: Timeout) {

// Note: _promiseRef mustn't have a type pattern, since it can be null
private[this] val (_ref: ActorRef[U], _future: Future[U], _promiseRef) =
private val (_ref: ActorRef[U], _future: Future[U], _promiseRef) =
if (target.isTerminated)
(
adapt.ActorRefAdapter[U](target.provider.deadLetters),
Expand Down
2 changes: 1 addition & 1 deletion actor/src/main/scala/org/apache/pekko/actor/Actor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ object Status {
* }}}
*/
trait ActorLogging { this: Actor =>
private var _log: LoggingAdapter = _
private var _log: LoggingAdapter = null

def log: LoggingAdapter = {
// only used in Actor, i.e. thread safe
Expand Down
6 changes: 3 additions & 3 deletions actor/src/main/scala/org/apache/pekko/actor/ActorCell.scala
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ private[pekko] class ActorCell(
with dungeon.DeathWatch
with dungeon.FaultHandling {

private[this] var _props = _initialProps
private var _props = _initialProps
def props: Props = _props

import ActorCell._
Expand All @@ -445,11 +445,11 @@ private[pekko] class ActorCell(
override final def classicActorContext: ActorContext = this

protected def uid: Int = self.path.uid
private[this] var _actor: Actor = _
private var _actor: Actor = _
def actor: Actor = _actor
var currentMessage: Envelope = _
private var behaviorStack: List[Actor.Receive] = emptyBehaviorStack
private[this] var sysmsgStash: LatestFirstSystemMessageList = SystemMessageList.LNil
private var sysmsgStash: LatestFirstSystemMessageList = SystemMessageList.LNil

// Java API
final def getParent() = parent
Expand Down
4 changes: 2 additions & 2 deletions actor/src/main/scala/org/apache/pekko/actor/ActorRef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,8 @@ private[pekko] class VirtualPathContainer(
// AddressTerminatedTopic must be updated together with the variables here.
// Important: don't include calls to sendSystemMessage inside the synchronized since that can
// result in deadlock, see issue #26326
private[this] var watching = ActorCell.emptyActorRefSet
private[this] var _watchedBy: OptionVal[Set[ActorRef]] = OptionVal.Some(ActorCell.emptyActorRefSet)
private var watching = ActorCell.emptyActorRefSet
private var _watchedBy: OptionVal[Set[ActorRef]] = OptionVal.Some(ActorCell.emptyActorRefSet)

/**
* INTERNAL API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ private[pekko] class LocalActorRefProvider private[pekko] (

override val ignoreRef: ActorRef = new IgnoreActorRef(this)

private[this] final val terminationPromise: Promise[Terminated] = Promise[Terminated]()
private final val terminationPromise: Promise[Terminated] = Promise[Terminated]()

def terminationFuture: Future[Terminated] = terminationPromise.future

Expand Down Expand Up @@ -494,7 +494,7 @@ private[pekko] class LocalActorRefProvider private[pekko] (
* but it also requires these references to be @volatile and lazy.
*/
@volatile
private var system: ActorSystemImpl = _
private var system: ActorSystemImpl = null

@volatile
private var extraNames: Map[String, InternalActorRef] = Map()
Expand Down
8 changes: 4 additions & 4 deletions actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ private[pekko] class ActorSystemImpl(
dynamicAccess.createInstanceFor[LoggingFilter](LoggingFilter, arguments).get
}

private[this] val markerLogging =
private val markerLogging =
new MarkerLoggingAdapter(eventStream, getClass.getName + "(" + name + ")", this.getClass, logFilter)
val log: LoggingAdapter = markerLogging

Expand Down Expand Up @@ -1018,7 +1018,7 @@ private[pekko] class ActorSystemImpl(

val dispatcher: ExecutionContextExecutor = dispatchers.defaultGlobalDispatcher

private[this] final val terminationCallbacks = new TerminationCallbacks(provider.terminationFuture)(dispatcher)
private final val terminationCallbacks = new TerminationCallbacks(provider.terminationFuture)(dispatcher)

override def whenTerminated: Future[Terminated] = terminationCallbacks.terminationFuture
override def getWhenTerminated: CompletionStage[Terminated] = whenTerminated.asJava
Expand Down Expand Up @@ -1323,8 +1323,8 @@ private[pekko] class ActorSystemImpl(
}

final class TerminationCallbacks[T](upStreamTerminated: Future[T])(implicit ec: ExecutionContext) {
private[this] final val done = Promise[T]()
private[this] final val ref = new AtomicReference(done)
private final val done = Promise[T]()
private final val ref = new AtomicReference(done)

// onComplete never fires twice so safe to avoid null check
upStreamTerminated.onComplete { t =>
Expand Down
6 changes: 3 additions & 3 deletions actor/src/main/scala/org/apache/pekko/actor/FSM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ object FSM {
private[pekko] final case class Timer(name: String, msg: Any, mode: TimerMode, generation: Int, owner: AnyRef)(
context: ActorContext)
extends NoSerializationVerificationNeeded {
private var ref: Option[Cancellable] = _
private var ref: Option[Cancellable] = None
private val scheduler = context.system.scheduler
private implicit val executionContext: ExecutionContextExecutor = context.dispatcher

Expand Down Expand Up @@ -733,9 +733,9 @@ trait FSM[S, D] extends Actor with Listeners with ActorLogging {
/*
* FSM State data and current timeout handling
*/
private var currentState: State = _
private var currentState: State = null
private var timeoutFuture: Option[Cancellable] = None
private var nextState: State = _
private var nextState: State = null
private var generation: Long = 0L

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private[pekko] class TypedCreatorFunctionConsumer(clz: Class[? <: Actor], creato
*/
private[pekko] class ArgsReflectConstructor(clz: Class[? <: Actor], args: immutable.Seq[Any])
extends IndirectActorProducer {
private[this] val constructor = Reflect.findConstructor(clz, args)
private val constructor = Reflect.findConstructor(clz, args)
override def actorClass = clz
override def produce() = Reflect.instantiate(constructor, args)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class LightArrayRevolverScheduler(config: Config, log: LoggingAdapter, threadFac
}

object LightArrayRevolverScheduler {
private[this] val taskHandle: VarHandle = {
private val taskHandle: VarHandle = {
val lookup = MethodHandles.privateLookupIn(classOf[TaskHolder], MethodHandles.lookup())
lookup.findVarHandle(classOf[TaskHolder], "task", classOf[Runnable])
}
Expand Down Expand Up @@ -417,8 +417,8 @@ object LightArrayRevolverScheduler {
override def isCancelled: Boolean = task eq CancelledTask
}

private[this] val CancelledTask = new Runnable { def run = () }
private[this] val ExecutedTask = new Runnable { def run = () }
private val CancelledTask = new Runnable { def run = () }
private val ExecutedTask = new Runnable { def run = () }

private val NotCancellable: TimerTask = new TimerTask {
def cancel(): Boolean = false
Expand Down
6 changes: 3 additions & 3 deletions actor/src/main/scala/org/apache/pekko/actor/Props.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ final case class Props(deploy: Deploy, clazz: Class[?], args: immutable.Seq[Any]

// derived property, does not need to be serialized
@transient
private[this] var _producer: IndirectActorProducer = _
private var _producer: IndirectActorProducer = null

// derived property, does not need to be serialized
@transient
private[this] var _cachedActorClass: Class[? <: Actor] = _
private var _cachedActorClass: Class[? <: Actor] = null

/**
* INTERNAL API
Expand All @@ -143,7 +143,7 @@ final case class Props(deploy: Deploy, clazz: Class[?], args: immutable.Seq[Any]
_producer
}

private[this] def cachedActorClass: Class[? <: Actor] = {
private def cachedActorClass: Class[? <: Actor] = {
if (_cachedActorClass eq null)
_cachedActorClass = producer.actorClass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ private[pekko] class UnstartedCell(
* This lock protects all accesses to this cell’s queues. It also ensures
* safe switching to the started ActorCell.
*/
private[this] final val lock = new ReentrantLock
private final val lock = new ReentrantLock

// use Envelope to keep on-send checks in the same place ACCESS MUST BE PROTECTED BY THE LOCK
private[this] final val queue = new JLinkedList[Envelope]()
private final val queue = new JLinkedList[Envelope]()

// ACCESS MUST BE PROTECTED BY THE LOCK
private[this] var sysmsgQueue: LatestFirstSystemMessageList = SystemMessageList.LNil
private var sysmsgQueue: LatestFirstSystemMessageList = SystemMessageList.LNil

import systemImpl.settings.UnstartedPushTimeout.{ duration => timeout }

Expand Down Expand Up @@ -305,7 +305,7 @@ private[pekko] class UnstartedCell(

def isLocal = true

private[this] final def cellIsReady(cell: Cell): Boolean = (cell ne this) && (cell ne null)
private final def cellIsReady(cell: Cell): Boolean = (cell ne this) && (cell ne null)

def hasMessages: Boolean = locked {
val cell = self.underlying
Expand All @@ -317,7 +317,7 @@ private[pekko] class UnstartedCell(
if (cellIsReady(cell)) cell.numberOfMessages else queue.size
}

private[this] final def locked[T](body: => T): T = {
private final def locked[T](body: => T): T = {
lock.lock()
try body
finally lock.unlock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ abstract class MessageDispatcher(val configurator: MessageDispatcherConfigurator
val mailboxes = prerequisites.mailboxes
val eventStream = prerequisites.eventStream

@nowarn @volatile private[this] var _inhabitantsDoNotCallMeDirectly: Long = _ // DO NOT TOUCH!
@nowarn @volatile private[this] var _shutdownScheduleDoNotCallMeDirectly: Int = _ // DO NOT TOUCH!
@nowarn @volatile private var _inhabitantsDoNotCallMeDirectly: Long = _ // DO NOT TOUCH!
@nowarn @volatile private var _shutdownScheduleDoNotCallMeDirectly: Int = _ // DO NOT TOUCH!
@nowarn private def _preventPrivateUnusedErasure = {
_inhabitantsDoNotCallMeDirectly
_shutdownScheduleDoNotCallMeDirectly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ private[pekko] trait Batchable extends Runnable {
private[pekko] trait BatchingExecutor extends Executor {

// invariant: if "_tasksLocal.get ne null" then we are inside Batch.run; if it is null, we are outside
private[this] val _tasksLocal = new ThreadLocal[AbstractBatch]()
private val _tasksLocal = new ThreadLocal[AbstractBatch]()

private[this] abstract class AbstractBatch extends java.util.ArrayDeque[Runnable](4) with Runnable {
private abstract class AbstractBatch extends java.util.ArrayDeque[Runnable](4) with Runnable {
@tailrec final def processBatch(batch: AbstractBatch): Unit =
if ((batch eq this) && !batch.isEmpty) {
batch.pollFirst().run()
Expand All @@ -84,7 +84,7 @@ private[pekko] trait BatchingExecutor extends Executor {
}
}

private[this] final class Batch extends AbstractBatch {
private final class Batch extends AbstractBatch {
override final def run(): Unit = {
require(_tasksLocal.get eq null)
_tasksLocal.set(this) // Install ourselves as the current batch
Expand All @@ -97,9 +97,9 @@ private[pekko] trait BatchingExecutor extends Executor {
}
}

private[this] val _blockContext = new ThreadLocal[BlockContext]()
private val _blockContext = new ThreadLocal[BlockContext]()

private[this] final class BlockableBatch extends AbstractBatch with BlockContext {
private final class BlockableBatch extends AbstractBatch with BlockContext {
// this method runs in the delegate ExecutionContext's thread
override final def run(): Unit = {
require(_tasksLocal.get eq null)
Expand Down
6 changes: 3 additions & 3 deletions actor/src/main/scala/org/apache/pekko/dispatch/Mailbox.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private[pekko] abstract class Mailbox(val messageQueue: MessageQueue)
* stay as it is.
*/
@volatile
var actor: ActorCell = _
var actor: ActorCell = null
def setActor(cell: ActorCell): Unit = actor = cell

def dispatcher: MessageDispatcher = actor.dispatcher
Expand Down Expand Up @@ -116,10 +116,10 @@ private[pekko] abstract class Mailbox(val messageQueue: MessageQueue)
def numberOfMessages: Int = messageQueue.numberOfMessages

@volatile
protected var _statusDoNotCallMeDirectly: Status = _ // 0 by default
protected var _statusDoNotCallMeDirectly: Status = 0 // 0 by default

@volatile
protected var _systemQueueDoNotCallMeDirectly: SystemMessage = _ // null by default
protected var _systemQueueDoNotCallMeDirectly: SystemMessage = null // null by default

// volatile read: the status is published across threads via compareAndSet/setVolatile
// below; a plain VarHandle.get could observe a stale status (e.g. miss a Scheduled or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ private[affinity] object AffinityPool {
// Following are auxiliary class and trait definitions
private final class IdleStrategy(idleCpuLevel: Int) {

private[this] val maxSpins = 1100 * idleCpuLevel - 1000
private[this] val maxYields = 5 * idleCpuLevel
private[this] val minParkPeriodNs = 1
private[this] val maxParkPeriodNs = MICROSECONDS.toNanos(250 - ((80 * (idleCpuLevel - 1)) / 3))
private val maxSpins = 1100 * idleCpuLevel - 1000
private val maxYields = 5 * idleCpuLevel
private val minParkPeriodNs = 1
private val maxParkPeriodNs = MICROSECONDS.toNanos(250 - ((80 * (idleCpuLevel - 1)) / 3))

private[this] var state: IdleState = Initial
private[this] var turns = 0L
private[this] var parkPeriodNs = 0L
@volatile private[this] var idling = false
private var state: IdleState = Initial
private var turns = 0L
private var parkPeriodNs = 0L
@volatile private var idling = false

private[this] def transitionTo(newState: IdleState): Unit = {
private def transitionTo(newState: IdleState): Unit = {
state = newState
turns = 0
}
Expand Down Expand Up @@ -148,8 +148,8 @@ private[pekko] class AffinityPool(
// indicates the current state of the pool
@volatile final private var poolState: PoolState = Uninitialized

private[this] final val workQueues = Array.fill(parallelism)(new BoundedAffinityTaskQueue(affinityGroupSize))
private[this] final val workers = mutable.Set[AffinityPoolWorker]()
private final val workQueues = Array.fill(parallelism)(new BoundedAffinityTaskQueue(affinityGroupSize))
private final val workers = mutable.Set[AffinityPoolWorker]()

def start(): this.type = {
bookKeepingLock.lock()
Expand Down Expand Up @@ -263,7 +263,7 @@ private[pekko] class AffinityPool(
override def toString: String =
s"${Logging.simpleName(this)}(id = $id, parallelism = $parallelism, affinityGroupSize = $affinityGroupSize, threadFactory = $threadFactory, idleCpuLevel = $idleCpuLevel, queueSelector = $queueSelector, rejectionHandler = $rejectionHandler)"

private[this] final class AffinityPoolWorker(val q: BoundedAffinityTaskQueue, val idleStrategy: IdleStrategy)
private final class AffinityPoolWorker(val q: BoundedAffinityTaskQueue, val idleStrategy: IdleStrategy)
extends Runnable {
val thread: Thread = threadFactory.newThread(this)

Expand Down Expand Up @@ -427,7 +427,7 @@ private[pekko] final class ThrowOnOverflowRejectionHandler extends RejectionHand
private[pekko] final class FairDistributionHashCache(val config: Config) extends QueueSelectorFactory {
private final val MaxFairDistributionThreshold = 2048

private[this] final val fairDistributionThreshold = config
private final val fairDistributionThreshold = config
.getInt("fair-work-distribution.threshold")
.requiring(
thr => 0 <= thr && thr <= MaxFairDistributionThreshold,
Expand All @@ -437,7 +437,7 @@ private[pekko] final class FairDistributionHashCache(val config: Config) extends
new AtomicReference[ImmutableIntMap](ImmutableIntMap.empty) with QueueSelector {
override def toString: String =
s"FairDistributionHashCache(fairDistributionThreshold = $fairDistributionThreshold)"
private[this] final def improve(h: Int): Int =
private final def improve(h: Int): Int =
0x7FFFFFFF & (reverseBytes(h * 0x9E3775CD) * 0x9E3775CD) // `sbhash`: In memory of Phil Bagwell.
override final def getQueue(command: Runnable, queues: Int): Int = {
val runnableHash = command.hashCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private[pekko] class EarliestFirstSystemMessageList(val head: SystemMessage) ext
private[pekko] sealed trait SystemMessage extends PossiblyHarmful with Serializable {
// Next fields are only modifiable via the SystemMessageList value class
@transient
private[sysmsg] var next: SystemMessage = _
private[sysmsg] var next: SystemMessage = null

def unlink(): Unit = next = null

Expand Down
2 changes: 1 addition & 1 deletion actor/src/main/scala/org/apache/pekko/event/Logging.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ trait LoggingBus extends ActorEventBus {

private val guard = new ReentrantLock()
private var loggers = Seq.empty[ActorRef]
@volatile private var _logLevel: LogLevel = _
@volatile private var _logLevel: LogLevel = OffLevel

/**
* Query currently set log level. See object Logging for more information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ trait BufferPool {
* benefit to wrapping in-heap JVM data when writing with NIO.
*/
private[pekko] class DirectByteBufferPool(defaultBufferSize: Int, maxPoolEntries: Int) extends BufferPool {
private[this] val pool: Array[ByteBuffer] = new Array[ByteBuffer](maxPoolEntries)
private[this] var buffersInPool: Int = 0
private val pool: Array[ByteBuffer] = new Array[ByteBuffer](maxPoolEntries)
private var buffersInPool: Int = 0

def acquire(): ByteBuffer =
takeBufferFromPool()
Expand Down
Loading