| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #ifndef SOPHIAR2_DEBUG_MACRO_H
- #define SOPHIAR2_DEBUG_MACRO_H
- #include "core/timestamp_helper.hpp"
- #include <boost/asio/awaitable.hpp>
- #include <boost/asio/high_resolution_timer.hpp>
- #include <boost/asio/this_coro.hpp>
- #include <boost/asio/use_awaitable.hpp>
- #include <spdlog/spdlog.h>
- #include <iostream>
- #define FILE_LINE_TRACE {\
- std::cout << fmt::format("F:{} L:{} T:{}", \
- __FILE_NAME__, __LINE__, sophiar::current_timestamp()) \
- << std::endl; }
- #define FILE_LINE_TRACE_WITH_THIS {\
- std::cout << fmt::format("F:{} L:{} T:{} TH:{}", \
- __FILE_NAME__, __LINE__, sophiar::current_timestamp(), (void *) this) \
- << std::endl; }
- #define PRINT_PTR(obj) {\
- std::cout << fmt::format("F:{} L:{} PTR: {}", __FILE_NAME__, __LINE__, \
- (void*)std::addressof(obj)) << std::endl; }
- #define ENSURE(func) \
- { \
- bool ok = (func); \
- if (!ok) return false; \
- }
- #define CO_ENSURE(func) \
- { \
- bool ok = co_await (func); \
- if (!ok) co_return false; \
- }
- namespace sophiar {
- using boost::asio::awaitable;
- using boost::asio::use_awaitable;
- template<typename DurationType>
- inline awaitable<void> coro_sleep(DurationType t) {
- boost::asio::high_resolution_timer timer(co_await boost::asio::this_coro::executor);
- timer.expires_from_now(t);
- co_await timer.async_wait(use_awaitable);
- co_return;
- }
- }
- #endif //SOPHIAR2_DEBUG_MACRO_H
|