Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
cb2362ce
Commit
cb2362ce
authored
12 years ago
by
Tadashi G. Takaoka
Committed by
Android (Google) Code Review
12 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Make some usages of SparseArray thread-safe" into jb-mr1-dev
parents
2cd248ee
8ce351a8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/latin/BinaryDictionary.java
+16
-11
16 additions, 11 deletions
java/src/com/android/inputmethod/latin/BinaryDictionary.java
with
16 additions
and
11 deletions
java/src/com/android/inputmethod/latin/BinaryDictionary.java
+
16
−
11
View file @
cb2362ce
...
@@ -64,18 +64,21 @@ public class BinaryDictionary extends Dictionary {
...
@@ -64,18 +64,21 @@ public class BinaryDictionary extends Dictionary {
private
final
SparseArray
<
DicTraverseSession
>
mDicTraverseSessions
=
private
final
SparseArray
<
DicTraverseSession
>
mDicTraverseSessions
=
new
SparseArray
<
DicTraverseSession
>();
new
SparseArray
<
DicTraverseSession
>();
// TODO: There should be a way to remove used DicTraverseSession objects from
// {@code mDicTraverseSessions}.
private
DicTraverseSession
getTraverseSession
(
int
traverseSessionId
)
{
private
DicTraverseSession
getTraverseSession
(
int
traverseSessionId
)
{
DicTraverseSession
traverseSession
=
mDicTraverseSessions
.
get
(
traverseSessionId
);
synchronized
(
mDicTraverseSessions
)
{
if
(
traverseSession
==
null
)
{
DicTraverseSession
traverseSession
=
mDicTraverseSessions
.
get
(
traverseSessionId
);
synchronized
(
mDicT
raverseSession
s
)
{
if
(
t
raverseSession
==
null
)
{
traverseSession
=
mDicTraverseSessions
.
get
(
traverseSessionId
);
traverseSession
=
mDicTraverseSessions
.
get
(
traverseSessionId
);
if
(
traverseSession
==
null
)
{
if
(
traverseSession
==
null
)
{
traverseSession
=
new
DicTraverseSession
(
mLocale
,
mNativeDict
);
traverseSession
=
new
DicTraverseSession
(
mLocale
,
mNativeDict
);
mDicTraverseSessions
.
put
(
traverseSessionId
,
traverseSession
);
mDicTraverseSessions
.
put
(
traverseSessionId
,
traverseSession
);
}
}
}
}
return
traverseSession
;
}
}
return
traverseSession
;
}
}
/**
/**
...
@@ -209,18 +212,20 @@ public class BinaryDictionary extends Dictionary {
...
@@ -209,18 +212,20 @@ public class BinaryDictionary extends Dictionary {
}
}
@Override
@Override
public
synchronized
void
close
()
{
public
void
close
()
{
for
(
int
i
=
0
;
i
<
mDicTraverseSessions
.
size
();
++
i
)
{
synchronized
(
mDicTraverseSessions
)
{
final
int
key
=
mDicTraverseSessions
.
keyAt
(
i
);
final
int
sessionsSize
=
mDicTraverseSessions
.
size
();
final
DicTraverseSession
traverseSession
=
mDicTraverseSessions
.
get
(
key
);
for
(
int
index
=
0
;
index
<
sessionsSize
;
++
index
)
{
if
(
traverseSession
!=
null
)
{
final
DicTraverseSession
traverseSession
=
mDicTraverseSessions
.
valueAt
(
index
);
traverseSession
.
close
();
if
(
traverseSession
!=
null
)
{
traverseSession
.
close
();
}
}
}
}
}
closeInternal
();
closeInternal
();
}
}
private
void
closeInternal
()
{
private
synchronized
void
closeInternal
()
{
if
(
mNativeDict
!=
0
)
{
if
(
mNativeDict
!=
0
)
{
closeNative
(
mNativeDict
);
closeNative
(
mNativeDict
);
mNativeDict
=
0
;
mNativeDict
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment