Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Yuta HIGUCHI
2014-10-20 09:10:28 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
633cf88992cce2a51295375aee5774463ad72ce2
633cf889
1 parent
8d143d2a
KryoNamespace as KryoFactory
Change-Id: I4b78433f08d01619b89f37a961213660a8e3c2db
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
utils/misc/src/main/java/org/onlab/util/KryoNamespace.java
utils/misc/src/main/java/org/onlab/util/KryoNamespace.java
View file @
633cf88
...
...
@@ -13,6 +13,7 @@ import com.esotericsoftware.kryo.io.ByteBufferInput;
import
com.esotericsoftware.kryo.io.ByteBufferOutput
;
import
com.esotericsoftware.kryo.io.Input
;
import
com.esotericsoftware.kryo.io.Output
;
import
com.esotericsoftware.kryo.pool.KryoFactory
;
import
com.google.common.collect.ImmutableList
;
// TODO Add tests for this class.
...
...
@@ -20,7 +21,7 @@ import com.google.common.collect.ImmutableList;
* Pool of Kryo instances, with classes pre-registered.
*/
//@ThreadSafe
public
final
class
KryoNamespace
{
public
final
class
KryoNamespace
implements
KryoFactory
{
/**
* Default buffer size used for serialization.
...
...
@@ -116,7 +117,7 @@ public final class KryoNamespace {
public
KryoNamespace
populate
(
int
instances
)
{
List
<
Kryo
>
kryos
=
new
ArrayList
<>(
instances
);
for
(
int
i
=
0
;
i
<
instances
;
++
i
)
{
kryos
.
add
(
newKryoInstanc
e
());
kryos
.
add
(
creat
e
());
}
pool
.
addAll
(
kryos
);
return
this
;
...
...
@@ -130,7 +131,7 @@ public final class KryoNamespace {
public
Kryo
getKryo
()
{
Kryo
kryo
=
pool
.
poll
();
if
(
kryo
==
null
)
{
return
newKryoInstanc
e
();
return
creat
e
();
}
return
kryo
;
}
...
...
@@ -235,7 +236,8 @@ public final class KryoNamespace {
*
* @return Kryo instance
*/
private
Kryo
newKryoInstance
()
{
@Override
public
Kryo
create
()
{
Kryo
kryo
=
new
Kryo
();
kryo
.
setRegistrationRequired
(
registrationRequired
);
for
(
Pair
<
Class
<?>,
Serializer
<?>>
registry
:
registeredTypes
)
{
...
...
Please
register
or
login
to post a comment