if (!types.isEmpty()) {
blocks.add(new RegistrationBlock(this.blockHeadId, types));
}
- return new Namespace(blocks, classLoader, friendlyName).populate(1);
+ return new Namespace(blocks, classLoader, friendlyName);
}
/**
this.registeredBlocks = ImmutableList.copyOf(registeredTypes);
this.classLoader = classLoader;
this.friendlyName = requireNonNull(friendlyName);
- }
-
- /**
- * Populates the Kryo pool.
- *
- * @param instances to add to the pool
- * @return this
- */
- public Namespace populate(int instances) {
- for (int i = 0; i < instances; ++i) {
- release(create());
- }
- return this;
+ // Pre-populate with a single instance
+ release(create());
}
/**
}
}
- /**
- * Gets the number of classes registered in this Kryo namespace.
- *
- * @return size of namespace
- */
- public int size() {
- return (int) registeredBlocks.stream()
- .flatMap(block -> block.types().stream())
- .count();
- }
-
/**
* Creates a Kryo instance.
*