optimize when msg.getCallback() not null
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- android, java
- Domain
- mobile-dev
Research direction
Start by locating WeakHandler's sendMessage, sendMessageAtFrontOfQueue, sendMessageAtTime, and sendMessageDelayed methods, then inspect how getCallback() messages are currently handled. Verify the callback path for immediate, front-of-queue, absolute-time, and delayed sends, and consider the issue's examples as the completion cases.
Written by the indexing model from the issue text.
Description
leak could still occur when used like bellow:
WeakHandler handler = new WeakHandler();
Message m = Message.obtain(handler.getExecHandler(), new Runnable() {
@Override
public void run() {
//do something
}
});
handler.sendMessageDelayed(m, delaytimes);
although postDelay() should be used here, but what if when we get message like this:
Message message = Message.obtain(m);
and m has a callback?
so maybe sendMessageXX() methods should be optimized:
public final boolean sendMessage(Message msg) {
if (msg.getCallback() != null) {
return mExec.post(msg.getCallback());
}
return mExec.sendMessage(msg);
}
public final boolean sendMessageAtFrontOfQueue(Message msg) {
if (msg.getCallback() != null) {
return postAtFrontOfQueue(msg.getCallback());
}
return mExec.sendMessageAtFrontOfQueue(msg);
}
public boolean sendMessageAtTime(Message msg, long uptimeMillis) {
if (msg.getCallback() != null) {
return postDelayed(msg.getCallback(), uptimeMillis);
}
return mExec.sendMessageAtTime(msg, uptimeMillis);
}
public final boolean sendMessageDelayed(Message msg, long delayMillis) {
if (msg.getCallback() != null) {
return postDelayed(msg.getCallback(), delayMillis);
}
return mExec.sendMessageDelayed(msg, delayMillis);
}
- Dominant language
- Java
- Stars
- 1.5k
- Forks
- 282
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from badoo/android-weak-handler
-
Dependency Dashboard Open
Difficulty 2/5 1-3 hours Newbie friendliness 10/100
-
Difficulty 3/5 1-2 days Newbie friendliness 20/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
badoo/android-weak-handler#17 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
badoo/android-weak-handler#12 · 1 comment ·
All issues in badoo/android-weak-handler
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100