diff --git a/project_tasks/src/main/scala/Transaction.scala b/project_tasks/src/main/scala/Transaction.scala index 3f13c1d..34f71fe 100644 --- a/project_tasks/src/main/scala/Transaction.scala +++ b/project_tasks/src/main/scala/Transaction.scala @@ -1,5 +1,6 @@ import exceptions._ import scala.collection.mutable +import scala.collection.mutable._ object TransactionStatus extends Enumeration { val SUCCESS, PENDING, FAILED = Value @@ -10,21 +11,21 @@ class TransactionQueue { // TODO // project task 1.1 // Add datastructure to contain the transactions - + var queue: Queue[Transaction] = Queue() // Remove and return the first element from the queue - def pop: Transaction = ??? + def pop: Transaction = {queue.synchronized(queue.dequeue())} // Return whether the queue is empty - def isEmpty: Boolean = ??? + def isEmpty: Boolean = {queue.synchronized(queue.isEmpty())} // Add new element to the back of the queue - def push(t: Transaction): Unit = ??? + def push(t: Transaction): Unit = {queue.synchronized(queue.push(t))} // Return the first element from the queue without removing it - def peek: Transaction = ??? + def peek: Transaction = {queue.synchronized(queue.front())} // Return an iterator to allow you to iterate over the queue - def iterator: Iterator[Transaction] = ??? + def iterator: Iterator[Transaction] = {queue.synchronized(queue.iterator())} } class Transaction(val transactionsQueue: TransactionQueue,