Revision 46b572b5
Added by Leszek Koltunski about 5 years ago
src/main/java/org/distorted/library/message/EffectMessageSender.java | ||
---|---|---|
1 | 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
2 | 2 |
// Copyright 2016 Leszek Koltunski // |
3 | 3 |
// // |
4 |
// This file is part of DistortedLibrary. //
|
|
4 |
// This file is part of Distorted. // |
|
5 | 5 |
// // |
6 |
// DistortedLibrary is free software: you can redistribute it and/or modify //
|
|
6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
7 | 7 |
// it under the terms of the GNU General Public License as published by // |
8 | 8 |
// the Free Software Foundation, either version 2 of the License, or // |
9 | 9 |
// (at your option) any later version. // |
10 | 10 |
// // |
11 |
// DistortedLibrary is distributed in the hope that it will be useful, //
|
|
11 |
// Distorted is distributed in the hope that it will be useful, // |
|
12 | 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
13 | 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
14 | 14 |
// GNU General Public License for more details. // |
15 | 15 |
// // |
16 | 16 |
// You should have received a copy of the GNU General Public License // |
17 |
// along with DistortedLibrary. If not, see <http://www.gnu.org/licenses/>. //
|
|
17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
18 | 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
19 | 19 |
|
20 | 20 |
package org.distorted.library.message; |
... | ... | |
49 | 49 |
private static EffectMessageSender mThis=null; |
50 | 50 |
private static volatile boolean mNotify = false; |
51 | 51 |
private static volatile boolean mRunning = false; |
52 |
private static final Object mLock = new Object(); |
|
52 | 53 |
|
53 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
54 | 55 |
|
55 | 56 |
private EffectMessageSender() |
56 | 57 |
{ |
58 |
|
|
57 | 59 |
} |
58 | 60 |
|
59 | 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
70 | 72 |
} |
71 | 73 |
else |
72 | 74 |
{ |
73 |
synchronized(mThis)
|
|
75 |
synchronized(mLock)
|
|
74 | 76 |
{ |
75 | 77 |
mThis.notify(); |
76 | 78 |
} |
... | ... | |
85 | 87 |
|
86 | 88 |
if( mThis!=null ) |
87 | 89 |
{ |
88 |
synchronized(mThis)
|
|
90 |
synchronized(mLock)
|
|
89 | 91 |
{ |
90 | 92 |
mThis.notify(); |
91 | 93 |
} |
... | ... | |
100 | 102 |
|
101 | 103 |
while(mRunning) |
102 | 104 |
{ |
103 |
//android.util.Log.i("SENDER", "sender thread running..."); |
|
104 |
|
|
105 | 105 |
while( mList.size()>0 ) |
106 | 106 |
{ |
107 | 107 |
tmp = mList.remove(0); |
108 | 108 |
tmp.mListener.effectMessage(tmp.mMessage, tmp.mEffectID, tmp.mObjectID); |
109 | 109 |
} |
110 | 110 |
|
111 |
synchronized(mThis)
|
|
111 |
synchronized(mLock)
|
|
112 | 112 |
{ |
113 | 113 |
if (!mNotify) |
114 | 114 |
{ |
... | ... | |
121 | 121 |
|
122 | 122 |
mThis = null; |
123 | 123 |
mList.clear(); |
124 |
|
|
125 |
//android.util.Log.i("SENDER", "sender thread finished..."); |
|
126 | 124 |
} |
127 | 125 |
|
128 | 126 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
132 | 130 |
Message msg = mThis.new Message(l,m,effID,objID); |
133 | 131 |
mList.add(msg); |
134 | 132 |
|
135 |
synchronized(mThis)
|
|
133 |
synchronized(mLock)
|
|
136 | 134 |
{ |
137 | 135 |
mNotify = true; |
138 | 136 |
mThis.notify(); |
Also available in: Unified diff
Correct the Legal notice.