Skip to content

Commit

Permalink
Rename to Synchronized
Browse files Browse the repository at this point in the history
  • Loading branch information
l3r8yJ committed May 26, 2023
1 parent 193e6e7 commit dce2aaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @author l3r8yJ
*/
@RequiredArgsConstructor
public final class FkSynchronizedStorage implements FkStorage {
public final class Synchronized implements FkStorage {

/**
* Lock.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import org.xembly.Directives;

/**
* Test case for {@link FkSynchronizedStorage}.
* Test case for {@link Synchronized}.
*
* @since 0.0.2
* @author l3r8yJ
*/
final class FkSynchronizedStorageTest {
final class SynchronizedTest {

private static final int N_THREADS = Runtime.getRuntime().availableProcessors();

Expand All @@ -30,11 +30,11 @@ final class FkSynchronizedStorageTest {
@Test
void readsAndWritesConcurrently() throws Exception {
final Stack<Integer> values = new Stack<>();
IntStream.range(0, FkSynchronizedStorageTest.N_THREADS).forEach(values::push);
final FkStorage storage = new FkSynchronizedStorage(
IntStream.range(0, SynchronizedTest.N_THREADS).forEach(values::push);
final FkStorage storage = new Synchronized(
new InFile("fake", "<stack/>")
);
for (int idx = 0; idx < FkSynchronizedStorageTest.N_THREADS; idx++) {
for (int idx = 0; idx < SynchronizedTest.N_THREADS; idx++) {
this.executors.submit(
() -> {
this.latch.await();
Expand All @@ -50,15 +50,15 @@ void readsAndWritesConcurrently() throws Exception {
}
this.latch.countDown();
final boolean failed = this.executors.awaitTermination(
(long) (FkSynchronizedStorageTest.N_THREADS / 2), TimeUnit.SECONDS
(long) (SynchronizedTest.N_THREADS / 2), TimeUnit.SECONDS
);
if (failed) {
throw new TimeoutException("FkSynchronizedStorageTest#readsAndWritesConcurrently() failed");
}
MatcherAssert.assertThat(
"Has size equal to stack size",
storage.xml().nodes("/stack/item"),
Matchers.hasSize(FkSynchronizedStorageTest.N_THREADS)
Matchers.hasSize(SynchronizedTest.N_THREADS)
);
}
}

1 comment on commit dce2aaa

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on dce2aaa May 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 22-576a91fb disappeared from src/main/java/io/github/eocqrs/xfake/InFile.java), that's why I closed #26. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.