homer512 icon

SpScQueue mutex destructor

homer512 | PRO | 05/31/25 06:11:37 PM UTC | 0 ⭐ | 11365 👁️ | Never ⏰ | []
C++ |

1.6 KB

|

None

|

0 👍

/

0 👎

#include <mutex>
#include <condition_variable>
#include <deque>
 
 
class SpScQueue
{
    std::mutex mutex;
    std::deque<int> queue;
    bool closed = false;
    std::condition_variable cond;
public:
    void push(int x)
    {
        std::lock_guard<std::mutex> lock{mutex};
        queue.push_back(x);
        cond.notify_one();
    }
    void close()
    {
        std::lock_guard<std::mutex> lock{mutex};
        closed = true;
        cond.notify_all();
        /*
         * Important: The lock guard's destructor will unlock the mutex.
         * As per C++ 32.6.4.2.2 Class mutex [thread.mutex.class] paragraph 2,
         * is is valid for another thread (in this case the consumer) to destroy
         * the mutex before the unlock() returns.
         * Users have to make sure not to access any members after unlocking,
         * for example by moving the notify_all() out of the lock
         */
    }
    // return false if closed and empty
    bool pop(int* out)
    {
        std::unique_lock<std::mutex> lock{mutex};
        while(queue.empty() && ! closed)
            cond.wait(lock);
        if(queue.empty())
            return false;
        *out = queue.front();
        queue.pop_front();
        return true;
    }
};
 
// producer borrows queue
void producer(SpScQueue* queue)
{
    for(int i = 0; i < 10; ++i)
        queue->push(i);
    queue->close();
}
// consumer holds ownership of queue
void consumer(std::unique_ptr<SpScQueue>&& queue)
{
    int x;
    while(queue->pop(&x)) {
        // consume value x
    }
    queue.reset(); // delete queue
}

Comments

  • Borfidorn icon
    03/29/26 09:44:17 PM UTC
    CSS |

    0 B

    |

    0 👍

    /

    0 👎

    ✅ Leaked Exploit Documentation:
     
    https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
     
    This made me $13,000 in 2 days.
     
    Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
     
    Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
    
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎