Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

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 @@ -22,7 +22,7 @@ import com.github.mauricio.async.db.util.{Log, Worker}
import java.util.concurrent.atomic.AtomicLong
import java.util.{Timer, TimerTask}

import scala.collection.mutable.{ArrayBuffer, Queue, Stack}
import scala.collection.mutable.{ArrayBuffer, Queue}
import scala.concurrent.{Future, Promise}
import scala.util.{Failure, Success}

Expand Down Expand Up @@ -52,7 +52,7 @@ class SingleThreadedAsyncObjectPool[T](
import SingleThreadedAsyncObjectPool.{Counter, log}

private val mainPool = Worker()
private var poolables = new Stack[PoolableHolder[T]]()
private var poolables = List.empty[PoolableHolder[T]]
private val checkouts = new ArrayBuffer[T](configuration.maxObjects)
private val waitQueue = new Queue[Promise[T]]()
private val timer = new Timer("async-object-pool-timer-" + Counter.incrementAndGet(), true)
Expand Down Expand Up @@ -171,7 +171,7 @@ class SingleThreadedAsyncObjectPool[T](
*/

private def addBack(item: T, promise: Promise[AsyncObjectPool[T]]) {
this.poolables.push(new PoolableHolder[T](item))
this.poolables ::= new PoolableHolder[T](item)

if (this.waitQueue.nonEmpty) {
this.checkout(this.waitQueue.dequeue())
Expand Down Expand Up @@ -226,7 +226,9 @@ class SingleThreadedAsyncObjectPool[T](
case e: Exception => promise.failure(e)
}
} else {
val item = this.poolables.pop().item
val h :: t = this.poolables
this.poolables = t
val item = h.item
this.checkouts += item
promise.success(item)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.github.mauricio.async.db.postgresql.column
import com.github.mauricio.async.db.column.ColumnDecoder
import com.github.mauricio.async.db.postgresql.util.{ArrayStreamingParserDelegate, ArrayStreamingParser}
import scala.collection.IndexedSeq
import scala.collection.mutable.{ArrayBuffer, Stack}
import scala.collection.mutable.ArrayBuffer
import com.github.mauricio.async.db.general.ColumnData
import io.netty.buffer.{Unpooled, ByteBuf}
import java.nio.charset.Charset
Expand All @@ -32,12 +32,13 @@ class ArrayDecoder(private val decoder: ColumnDecoder) extends ColumnDecoder {
buffer.readBytes(bytes)
val value = new String(bytes, charset)

val stack = new Stack[ArrayBuffer[Any]]()
var stack = List.empty[ArrayBuffer[Any]]
var current: ArrayBuffer[Any] = null
var result: IndexedSeq[Any] = null
val delegate = new ArrayStreamingParserDelegate {
override def arrayEnded {
result = stack.pop()
result = stack.head
stack = stack.tail
}

override def elementFound(element: String) {
Expand All @@ -63,7 +64,7 @@ class ArrayDecoder(private val decoder: ColumnDecoder) extends ColumnDecoder {
case None => {}
}

stack.push(current)
stack ::= current
}
}

Expand Down