Debian Codegraph @

scala-unit-tests/src/test/scala/org/eclipse/collections/impl/bag/mutable/MultiReaderHashBagTestTrait.scala

raw
1 /*
2 * Copyright (c) 2021 Goldman Sachs.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and Eclipse Distribution License v. 1.0 which accompany this distribution.
6 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7 * and the Eclipse Distribution License is available at
8 * http://www.eclipse.org/org/documents/edl-v10.php.
9 */
10
11 package org.eclipse.collections.impl.bag.mutable
12
13 import org.eclipse.collections.api.bag.MutableBag
14 import org.eclipse.collections.impl.MultiReaderThreadSafetyTestTrait
15 import org.eclipse.collections.impl.Prelude._
16
17 trait MultiReaderHashBagTestTrait extends MultiReaderThreadSafetyTestTrait
18 {
19 val classUnderTest: MultiReaderHashBag[Int]
20
21 def createReadLockHolderThread(gate: Gate): Thread =
22 spawn
23 {
24 this.classUnderTest.withReadLockAndDelegate((_: MutableBag[_]) => sleep(gate))
25 }
26
27 def createWriteLockHolderThread(gate: Gate): Thread =
28 spawn
29 {
30 this.classUnderTest.withWriteLockAndDelegate((_: MutableBag[_]) => sleep(gate))
31 }
32 }