projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
544c75a
)
Add lots of synchronization.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Fri, 29 Oct 2010 04:16:35 +0000
(06:16 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Fri, 29 Oct 2010 04:16:35 +0000
(06:16 +0200)
src/main/java/net/pterodactylus/sone/core/Core.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/Post.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/Profile.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/Reply.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/Sone.java
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/core/Core.java
b/src/main/java/net/pterodactylus/sone/core/Core.java
index
ab98316
..
99ebc6d
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/core/Core.java
+++ b/
src/main/java/net/pterodactylus/sone/core/Core.java
@@
-102,13
+102,13
@@
public class Core extends AbstractService {
private SoneDownloader soneDownloader;
/** The Sone blacklist. */
private SoneDownloader soneDownloader;
/** The Sone blacklist. */
- private final Set<Sone> blacklistedSones =
new HashSet<Sone>(
);
+ private final Set<Sone> blacklistedSones =
Collections.synchronizedSet(new HashSet<Sone>()
);
/** The local Sones. */
/** The local Sones. */
- private final Set<Sone> localSones =
new HashSet<Sone>(
);
+ private final Set<Sone> localSones =
Collections.synchronizedSet(new HashSet<Sone>()
);
/** Sone inserters. */
/** Sone inserters. */
- private final Map<Sone, SoneInserter> soneInserters =
new HashMap<Sone, SoneInserter>(
);
+ private final Map<Sone, SoneInserter> soneInserters =
Collections.synchronizedMap(new HashMap<Sone, SoneInserter>()
);
/** The Sones’ statuses. */
private final Map<Sone, SoneStatus> soneStatuses = Collections.synchronizedMap(new HashMap<Sone, SoneStatus>());
/** The Sones’ statuses. */
private final Map<Sone, SoneStatus> soneStatuses = Collections.synchronizedMap(new HashMap<Sone, SoneStatus>());
@@
-116,13
+116,13
@@
public class Core extends AbstractService {
/* various caches follow here. */
/** Cache for all known Sones. */
/* various caches follow here. */
/** Cache for all known Sones. */
- private final Map<String, Sone> soneCache =
new HashMap<String, Sone>(
);
+ private final Map<String, Sone> soneCache =
Collections.synchronizedMap(new HashMap<String, Sone>()
);
/** Cache for all known posts. */
/** Cache for all known posts. */
- private final Map<String, Post> postCache =
new HashMap<String, Post>(
);
+ private final Map<String, Post> postCache =
Collections.synchronizedMap(new HashMap<String, Post>()
);
/** Cache for all known replies. */
/** Cache for all known replies. */
- private final Map<String, Reply> replyCache =
new HashMap<String, Reply>(
);
+ private final Map<String, Reply> replyCache =
Collections.synchronizedMap(new HashMap<String, Reply>()
);
/**
* Creates a new core.
/**
* Creates a new core.
diff --git
a/src/main/java/net/pterodactylus/sone/data/Post.java
b/src/main/java/net/pterodactylus/sone/data/Post.java
index
d0938c9
..
c30665a
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/Post.java
+++ b/
src/main/java/net/pterodactylus/sone/data/Post.java
@@
-31,13
+31,13
@@
public class Post {
private final UUID id;
/** The Sone this post belongs to. */
private final UUID id;
/** The Sone this post belongs to. */
- private Sone sone;
+ private
volatile
Sone sone;
/** The time of the post (in milliseconds since Jan 1, 1970 UTC). */
/** The time of the post (in milliseconds since Jan 1, 1970 UTC). */
- private long time;
+ private
volatile
long time;
/** The text of the post. */
/** The text of the post. */
- private String text;
+ private
volatile
String text;
/**
* Creates a new post.
/**
* Creates a new post.
diff --git
a/src/main/java/net/pterodactylus/sone/data/Profile.java
b/src/main/java/net/pterodactylus/sone/data/Profile.java
index
72901b3
..
7c29430
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/Profile.java
+++ b/
src/main/java/net/pterodactylus/sone/data/Profile.java
@@
-26,25
+26,25
@@
package net.pterodactylus.sone.data;
public class Profile {
/** Whether the profile was modified. */
public class Profile {
/** Whether the profile was modified. */
- private boolean modified;
+ private
volatile
boolean modified;
/** The first name. */
/** The first name. */
- private String firstName;
+ private
volatile
String firstName;
/** The middle name(s). */
/** The middle name(s). */
- private String middleName;
+ private
volatile
String middleName;
/** The last name. */
/** The last name. */
- private String lastName;
+ private
volatile
String lastName;
/** The day of the birth date. */
/** The day of the birth date. */
- private Integer birthDay;
+ private
volatile
Integer birthDay;
/** The month of the birth date. */
/** The month of the birth date. */
- private Integer birthMonth;
+ private
volatile
Integer birthMonth;
/** The year of the birth date. */
/** The year of the birth date. */
- private Integer birthYear;
+ private
volatile
Integer birthYear;
/**
* Creates a new empty profile.
/**
* Creates a new empty profile.
diff --git
a/src/main/java/net/pterodactylus/sone/data/Reply.java
b/src/main/java/net/pterodactylus/sone/data/Reply.java
index
4429abf
..
05d8049
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/Reply.java
+++ b/
src/main/java/net/pterodactylus/sone/data/Reply.java
@@
-31,16
+31,16
@@
public class Reply {
private final UUID id;
/** The Sone that posted this reply. */
private final UUID id;
/** The Sone that posted this reply. */
- private Sone sone;
+ private
volatile
Sone sone;
/** The Post this reply refers to. */
/** The Post this reply refers to. */
- private Post post;
+ private
volatile
Post post;
/** The time of the reply. */
/** The time of the reply. */
- private long time;
+ private
volatile
long time;
/** The text of the reply. */
/** The text of the reply. */
- private String text;
+ private
volatile
String text;
/**
* Creates a new reply.
/**
* Creates a new reply.
diff --git
a/src/main/java/net/pterodactylus/sone/data/Sone.java
b/src/main/java/net/pterodactylus/sone/data/Sone.java
index
f6d5181
..
129293c
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/Sone.java
+++ b/
src/main/java/net/pterodactylus/sone/data/Sone.java
@@
-49,38
+49,38
@@
public class Sone {
private final UUID id;
/** The name of this Sone. */
private final UUID id;
/** The name of this Sone. */
- private String name;
+ private
volatile
String name;
/** The URI under which the Sone is stored in Freenet. */
/** The URI under which the Sone is stored in Freenet. */
- private FreenetURI requestUri;
+ private
volatile
FreenetURI requestUri;
/** The URI used to insert a new version of this Sone. */
/* This will be null for remote Sones! */
/** The URI used to insert a new version of this Sone. */
/* This will be null for remote Sones! */
- private FreenetURI insertUri;
+ private
volatile
FreenetURI insertUri;
/** The time of the last inserted update. */
/** The time of the last inserted update. */
- private long time;
+ private
volatile
long time;
/** The profile of this Sone. */
/** The profile of this Sone. */
- private Profile profile;
+ private
volatile
Profile profile;
/** All friend Sones. */
/** All friend Sones. */
- private final Set<Sone> friendSones =
new HashSet<Sone>(
);
+ private final Set<Sone> friendSones =
Collections.synchronizedSet(new HashSet<Sone>()
);
/** All posts. */
/** All posts. */
- private final Set<Post> posts =
new HashSet<Post>(
);
+ private final Set<Post> posts =
Collections.synchronizedSet(new HashSet<Post>()
);
/** All replies. */
/** All replies. */
- private final Set<Reply> replies =
new HashSet<Reply>(
);
+ private final Set<Reply> replies =
Collections.synchronizedSet(new HashSet<Reply>()
);
/** The IDs of all blocked Sones. */
/** The IDs of all blocked Sones. */
- private final Set<String> blockedSoneIds =
new HashSet<String>(
);
+ private final Set<String> blockedSoneIds =
Collections.synchronizedSet(new HashSet<String>()
);
/** The IDs of all liked posts. */
/** The IDs of all liked posts. */
- private final Set<String> likedPostIds =
new HashSet<String>(
);
+ private final Set<String> likedPostIds =
Collections.synchronizedSet(new HashSet<String>()
);
/** The IDs of all liked replies. */
/** The IDs of all liked replies. */
- private final Set<String> likedReplyIds =
new HashSet<String>(
);
+ private final Set<String> likedReplyIds =
Collections.synchronizedSet(new HashSet<String>()
);
/** Modification count. */
private volatile long modificationCounter = 0;
/** Modification count. */
private volatile long modificationCounter = 0;