LLFIO v2.00
Loading...
Searching...
No Matches
handle.hpp File Reference

Provides handle. More...

#include "deadline.h"
#include "native_handle_type.hpp"
#include "status_code.hpp"
#include <algorithm>
#include <cassert>

Classes

class  llfio_v2_xxx::handle
 A native_handle_type which is managed by the lifetime of this object instance. More...
 
union  llfio_v2_xxx::handle::alignas
 
struct  llfio_v2_xxx::construct< T >
 Metaprogramming shim for constructing any handle subclass. More...
 

Namespaces

namespace  llfio_v2_xxx
 The LLFIO namespace.
 

Functions

std::ostream & llfio_v2_xxx::operator<< (std::ostream &s, const handle &v)
 
std::ostream & llfio_v2_xxx::operator<< (std::ostream &s, const handle::mode &v)
 
std::ostream & llfio_v2_xxx::operator<< (std::ostream &s, const handle::creation &v)
 
std::ostream & llfio_v2_xxx::operator<< (std::ostream &s, const handle::caching &v)
 
std::ostream & llfio_v2_xxx::operator<< (std::ostream &s, const handle::flag &v)
 
template<class Dest , class Src >
void llfio_v2_xxx::detail::fill_failure_info (Dest &dest, const Src &src)
 
template<class T >
void llfio_v2_xxx::detail::log_inst_to_info (const handle *inst, const char *buffer)
 
void llfio_v2_xxx::swap (handle &self, handle &o) noexcept
 Swap with another instance.
 
result< void > llfio_v2_xxx::close (handle &self) noexcept
 Immediately close the native handle type managed by this handle.
 

Detailed Description

Provides handle.

Function Documentation

◆ fill_failure_info()

template<class Dest , class Src >
void llfio_v2_xxx::detail::fill_failure_info ( Dest &  dest,
const Src &  src 
)
inline
550 {
551 (void) src;
552 auto &tls = detail::tls_errored_results();
553 if(!tls.reentering_self)
554 {
555 handle *currenth = tls.current_handle;
556 native_handle_type nativeh;
557 if(currenth != nullptr)
558 {
559 nativeh = currenth->native_handle();
560 // This may fail, if it does it will construct an error_info thus reentering ourselves. Prevent that.
561 tls.reentering_self = true;
562 auto currentpath_ = currenth->current_path();
563 tls.reentering_self = false;
564 if(currentpath_)
565 {
566 auto currentpath = currentpath_.value().string();
567 dest._thread_id = tls.this_thread_id;
568#ifdef _MSC_VER
569#pragma warning(push)
570#pragma warning(disable : 4996) // the function may be unsafe
571#endif
572#if (__GNUC__ >= 8) && !defined(__clang__)
573#pragma GCC diagnostic push
574#pragma GCC diagnostic ignored "-Wstringop-overflow"
575#endif
576 // The type in TLS is char paths[190][16]{};
577 // If I index that by paths[x], I get back a type of char(&)[190].
578 // See https://godbolt.org/z/d69xzd for proof.
579 // So I don't know why there is a warning here about overflowing a buffer of 16!
580 strncpy(tls.next(dest._tls_path_id1), QUICKCPPLIB_NAMESPACE::ringbuffer_log::last190(currentpath), 190);
581#if (__GNUC__ >= 8) && !defined(__clang__)
582#pragma GCC diagnostic pop
583#endif
584#ifdef _MSC_VER
585#pragma warning(pop)
586#endif
587 dest._tls_path_id2 = dest._tls_path_id1 - 17; // guaranteed invalid
588 }
589 }
590#if LLFIO_LOGGING_LEVEL >= 2
591 if(log().log_level() >= log_level::error)
592 {
593 dest._log_id = log().emplace_back(log_level::error, src.message().c_str(), static_cast<uint32_t>(nativeh._init), tls.this_thread_id);
594 }
595#endif
596 }
597 }

◆ log_inst_to_info()

template<class T >
void llfio_v2_xxx::detail::log_inst_to_info ( const handle inst,
const char *  buffer 
)
672 {
673 (void) inst;
674 (void) buffer;
675 LLFIO_LOG_INFO(inst->native_handle()._init, buffer);
676 }