/*
 * SPDX-FileCopyrightText: 2025 Copyright contributors to the cppTango project
 *
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */
#include <tango/client/DelayedEventUnsubThread.h>

#include <tango/client/DelayEvent.h>
#include <tango/server/WriterLock.h>

namespace Tango
{

void DelayedEventUnsubThread::run(TANGO_UNUSED(void *ptr))
{
    try
    {
        //
        // In case a callback is still in its execution, wait for it to terminate
        //

        the_mon->timeout(3000);
        the_mon->get_monitor();
        the_mon->rel_monitor();

        //
        // Unsubscribe the event
        //

        TANGO_LOG_DEBUG << "DelayedEventUnsubThread calling unsubscribe_event for ID " << event_id << std::endl;

        ev_cons->unsubscribe_event(event_id);
    }
    catch(...)
    {
    }
}

} // namespace Tango
