Code Monkey home page Code Monkey logo

Comments (4)

dimikot avatar dimikot commented on July 28, 2024

Похоже на баг в компиляторе (вернее даже не столько баг, сколько побочный эффект оптимизатора), как это ни смешно. Как замена в строчке "storage.count(id)" может влиять на строчку "auto wrapper = &storage, callback, id {}" ?

map<ident_t, shared_ptr<Realplexor::Event::ITimer>> storage;

public:

CleanupTimers() {}

template<typename Cb>
void start_timer_for_id(ident_t id, int timeout, Cb callback)
{
    // Remove current timer if present.
    if (storage.count(id)) {
        storage[id]->remove();
        storage.erase(id);
    }
    // Create new timer.
    auto wrapper = [&storage, callback, id](int) { 
        auto guard = storage[id];
        storage.erase(id); // thanks to guard, the timer is deleted only when we exit this closure
        callback(); // it is important for logs to call erase() before the callback
    };
    storage[id].reset(new Realplexor::Event::Timer<decltype(wrapper)>(wrapper));
    storage[id]->start(timeout);
}

Вот я нашел насчет этого: http://gcc.gnu.org/ml/gcc-help/2012-02/msg00203.html

Попробуйте сделать, как там написано, т.е. заменить на

auto wrapper = [this, callback, id](int) { 

Первую строчку, где storage.count(id), не меняйте - с ней все в порядке, нет смысла добавлять там "this->".

Если получится, сделайте pull request, я вмерджу. Спасибо!

from dklab_realplexor.

ZooKeeper avatar ZooKeeper commented on July 28, 2024
auto wrapper = [this, callback, id](int) { 

дает

Storage/CleanupTimers.h: In lambda function:
Storage/CleanupTimers.h:32:36: error: no match for 'operator[]' in '((Storage::CleanupTimers*)this)->Storage::CleanupTimers::storage[id]'

Проще всего Вам попробовать собрать с последними версиями пакетов, как видно из тредов это не изолированные проблемы, а изменившееся поведение gcc

from dklab_realplexor.

Timosha avatar Timosha commented on July 28, 2024

Timosha@a4baf8f и Timosha@b8bd2b7 позволяют собрать для gcc 4.7.2, после выхода 4.7.3 второе изменение можно убрать

from dklab_realplexor.

dimikot avatar dimikot commented on July 28, 2024

Данные коммиты вмерджены в основную ветку.

from dklab_realplexor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.