question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

putb(T msg, final long timeoutMillis)

See original GitHub issue

Hi, I read the MailBox.java and have a question. Why the method putb(T msg, final long timeoutMillis) not reput the msg when the mailbox is not full. But the method put(T msg, int timeoutMillis) reput the msg in a loop. Thanks.

    /**
     * put a non-null message in the mailbox, and block the calling thread  for timeoutMillis
     * if the mailbox is full. 
     */
    public void putb(T msg, final long timeoutMillis) {
        BlockingSubscriber evs = new BlockingSubscriber();
        if (!put(msg, evs)) {
            evs.blockingWait(timeoutMillis);
        }
        if (!evs.eventRcvd) {
            removeSpaceAvailableListener(evs);
        }
    }
/**
     * put a non-null message in the mailbox, and pause the calling task  for timeoutMillis
     * if the mailbox is full. 
     */

    public boolean put(T msg, int timeoutMillis) throws Pausable {
        final Task t = Task.getCurrentTask();
        long begin = System.currentTimeMillis();
        while (!put(msg, t)) {
            TimerTask tt = new TimerTask() {
                public void run() {
                    Mailbox.this.removeSpaceAvailableListener(t);
                    t.onEvent(Mailbox.this, timedOut);
                }
            };
            Task.timer.schedule(tt, timeoutMillis);
            Task.pause(this);
            removeSpaceAvailableListener(t);
            if (System.currentTimeMillis() - begin >= timeoutMillis) {
                return false;
            }
        }
        return true;
    }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
nqzerocommented, Feb 2, 2018

this is fixed (for both putb and getb) in kilim 2.0

@CurryGaifan thanks for noticing the inconsistency, and @zy416548283 thanks for explaining the significance to me

1reaction
walkerzhaocommented, Jan 19, 2018

@kilim @nqzero Here, we has similar question lastly.

The intention is the same in both: attempt to do a put until we run out of time.

But now, putb will not reput the msg into the mailbox; In some situations, this behavior may be dangerous.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · kilim/kilim - GitHub
Lightweight threads for Java, with message passing, nio, http and scheduling support. - Issues · kilim/kilim. ... Cell.putb(T msg, final long timeoutMillis).
Read more >
services/java/com/android/server/power ... - Google Git
Message : Sent when a user activity timeout occurs to update the power state. ... Timestamp of the last time the device was...
Read more >
java.util.concurrent.ArrayBlockingQueue.poll java code ...
Retrieves and removes buffer at the head of this queue, * waiting up to the specified wait time if necessary for an element...
Read more >
Failed to construct kafka producer with Springboot
Had a similar issue from my end I imported the wrong JsonSerializer class. Changed to this import ...
Read more >
API Proxy timeout - Google Cloud Community
Cloud customers, who can't modify the Edge timeouts, can also configure an API proxy timeout, as long as the timeout is shorter than...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found