// Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #if defined(__APPLE__) #pragma once #include #include #include #include #include #include #include #include "dns_sd.h" #include "wpi/util/Synchronization.h" #include "wpi/util/mutex.hpp" namespace wpi::net { class ResolverThread { private: struct private_init {}; public: explicit ResolverThread(const private_init&); ~ResolverThread() noexcept; void AddServiceRef(DNSServiceRef serviceRef, dnssd_sock_t socket); void RemoveServiceRefInThread(DNSServiceRef serviceRef); WPI_EventHandle RemoveServiceRefOutsideThread(DNSServiceRef serviceRef); static std::shared_ptr Get(); private: void ThreadMain(); bool CleanupRefs(); wpi::util::mutex serviceRefMutex; std::vector> serviceRefsToRemove; std::vector> serviceRefs; std::thread thread; std::atomic_bool running; }; } // namespace wpi::net #endif // defined(__APPLE__)