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

◆ log_inst_to_info()

template<class T >
void llfio_v2_xxx::detail::log_inst_to_info ( const handle inst,
const char *  buffer 
)
665 {
666 (void) inst;
667 (void) buffer;
668 LLFIO_LOG_INFO(inst->native_handle()._init, buffer);
669 }