diff options
Diffstat (limited to '3rdparty/asio/src/examples/cpp17')
9 files changed, 1470 insertions, 0 deletions
diff --git a/3rdparty/asio/src/examples/cpp17/Makefile.am b/3rdparty/asio/src/examples/cpp17/Makefile.am new file mode 100644 index 00000000000..c3a571c02f4 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/Makefile.am @@ -0,0 +1,37 @@ +AUTOMAKE_OPTIONS = subdir-objects + +if SEPARATE_COMPILATION +noinst_LIBRARIES = libasio.a +libasio_a_SOURCES = ../../asio.cpp +if HAVE_OPENSSL +libasio_a_SOURCES += ../../asio_ssl.cpp +endif +LDADD = libasio.a +endif + +if HAVE_COROUTINES +noinst_PROGRAMS = \ + coroutines_ts/chat_server \ + coroutines_ts/echo_server \ + coroutines_ts/echo_server_with_default \ + coroutines_ts/echo_server_with_as_single_default \ + coroutines_ts/echo_server_with_as_tuple_default \ + coroutines_ts/refactored_echo_server +endif + +AM_CXXFLAGS = -I$(srcdir)/../../../include + +if HAVE_COROUTINES +coroutines_ts_chat_server_SOURCES = coroutines_ts/chat_server.cpp +coroutines_ts_echo_server_SOURCES = coroutines_ts/echo_server.cpp +coroutines_ts_echo_server_with_default_SOURCES = coroutines_ts/echo_server_with_default.cpp +coroutines_ts_echo_server_with_as_single_default_SOURCES = coroutines_ts/echo_server_with_as_single_default.cpp +coroutines_ts_echo_server_with_as_tuple_default_SOURCES = coroutines_ts/echo_server_with_as_tuple_default.cpp +coroutines_ts_refactored_echo_server_SOURCES = coroutines_ts/refactored_echo_server.cpp +endif + +EXTRA_DIST = \ + coroutines_ts/range_based_for.cpp + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in diff --git a/3rdparty/asio/src/examples/cpp17/Makefile.in b/3rdparty/asio/src/examples/cpp17/Makefile.in new file mode 100644 index 00000000000..db35ec4f320 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/Makefile.in @@ -0,0 +1,738 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2021 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@HAVE_OPENSSL_TRUE@@SEPARATE_COMPILATION_TRUE@am__append_1 = ../../asio_ssl.cpp +@HAVE_COROUTINES_TRUE@noinst_PROGRAMS = \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/chat_server$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/echo_server$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/echo_server_with_default$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/echo_server_with_as_single_default$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/echo_server_with_as_tuple_default$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/refactored_echo_server$(EXEEXT) +subdir = src/examples/cpp17 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +PROGRAMS = $(noinst_PROGRAMS) +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +AM_V_AR = $(am__v_AR_@AM_V@) +am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) +am__v_AR_0 = @echo " AR " $@; +am__v_AR_1 = +libasio_a_AR = $(AR) $(ARFLAGS) +libasio_a_LIBADD = +am__libasio_a_SOURCES_DIST = ../../asio.cpp ../../asio_ssl.cpp +am__dirstamp = $(am__leading_dot)dirstamp +@HAVE_OPENSSL_TRUE@@SEPARATE_COMPILATION_TRUE@am__objects_1 = ../../asio_ssl.$(OBJEXT) +@SEPARATE_COMPILATION_TRUE@am_libasio_a_OBJECTS = \ +@SEPARATE_COMPILATION_TRUE@ ../../asio.$(OBJEXT) \ +@SEPARATE_COMPILATION_TRUE@ $(am__objects_1) +libasio_a_OBJECTS = $(am_libasio_a_OBJECTS) +am__coroutines_ts_chat_server_SOURCES_DIST = \ + coroutines_ts/chat_server.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_ts_chat_server_OBJECTS = \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/chat_server.$(OBJEXT) +coroutines_ts_chat_server_OBJECTS = \ + $(am_coroutines_ts_chat_server_OBJECTS) +coroutines_ts_chat_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_ts_chat_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_ts_echo_server_SOURCES_DIST = \ + coroutines_ts/echo_server.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_ts_echo_server_OBJECTS = \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/echo_server.$(OBJEXT) +coroutines_ts_echo_server_OBJECTS = \ + $(am_coroutines_ts_echo_server_OBJECTS) +coroutines_ts_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_ts_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_ts_echo_server_with_as_single_default_SOURCES_DIST = \ + coroutines_ts/echo_server_with_as_single_default.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_ts_echo_server_with_as_single_default_OBJECTS = coroutines_ts/echo_server_with_as_single_default.$(OBJEXT) +coroutines_ts_echo_server_with_as_single_default_OBJECTS = $(am_coroutines_ts_echo_server_with_as_single_default_OBJECTS) +coroutines_ts_echo_server_with_as_single_default_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_ts_echo_server_with_as_single_default_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_ts_echo_server_with_as_tuple_default_SOURCES_DIST = \ + coroutines_ts/echo_server_with_as_tuple_default.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_ts_echo_server_with_as_tuple_default_OBJECTS = coroutines_ts/echo_server_with_as_tuple_default.$(OBJEXT) +coroutines_ts_echo_server_with_as_tuple_default_OBJECTS = \ + $(am_coroutines_ts_echo_server_with_as_tuple_default_OBJECTS) +coroutines_ts_echo_server_with_as_tuple_default_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_ts_echo_server_with_as_tuple_default_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_ts_echo_server_with_default_SOURCES_DIST = \ + coroutines_ts/echo_server_with_default.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_ts_echo_server_with_default_OBJECTS = coroutines_ts/echo_server_with_default.$(OBJEXT) +coroutines_ts_echo_server_with_default_OBJECTS = \ + $(am_coroutines_ts_echo_server_with_default_OBJECTS) +coroutines_ts_echo_server_with_default_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_ts_echo_server_with_default_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_ts_refactored_echo_server_SOURCES_DIST = \ + coroutines_ts/refactored_echo_server.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_ts_refactored_echo_server_OBJECTS = coroutines_ts/refactored_echo_server.$(OBJEXT) +coroutines_ts_refactored_echo_server_OBJECTS = \ + $(am_coroutines_ts_refactored_echo_server_OBJECTS) +coroutines_ts_refactored_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_ts_refactored_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ../../$(DEPDIR)/asio.Po \ + ../../$(DEPDIR)/asio_ssl.Po \ + coroutines_ts/$(DEPDIR)/chat_server.Po \ + coroutines_ts/$(DEPDIR)/echo_server.Po \ + coroutines_ts/$(DEPDIR)/echo_server_with_as_single_default.Po \ + coroutines_ts/$(DEPDIR)/echo_server_with_as_tuple_default.Po \ + coroutines_ts/$(DEPDIR)/echo_server_with_default.Po \ + coroutines_ts/$(DEPDIR)/refactored_echo_server.Po +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(libasio_a_SOURCES) $(coroutines_ts_chat_server_SOURCES) \ + $(coroutines_ts_echo_server_SOURCES) \ + $(coroutines_ts_echo_server_with_as_single_default_SOURCES) \ + $(coroutines_ts_echo_server_with_as_tuple_default_SOURCES) \ + $(coroutines_ts_echo_server_with_default_SOURCES) \ + $(coroutines_ts_refactored_echo_server_SOURCES) +DIST_SOURCES = $(am__libasio_a_SOURCES_DIST) \ + $(am__coroutines_ts_chat_server_SOURCES_DIST) \ + $(am__coroutines_ts_echo_server_SOURCES_DIST) \ + $(am__coroutines_ts_echo_server_with_as_single_default_SOURCES_DIST) \ + $(am__coroutines_ts_echo_server_with_as_tuple_default_SOURCES_DIST) \ + $(am__coroutines_ts_echo_server_with_default_SOURCES_DIST) \ + $(am__coroutines_ts_refactored_echo_server_SOURCES_DIST) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +ETAGS = @ETAGS@ +EXEEXT = @EXEEXT@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfigdir = @pkgconfigdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = subdir-objects +@SEPARATE_COMPILATION_TRUE@noinst_LIBRARIES = libasio.a +@SEPARATE_COMPILATION_TRUE@libasio_a_SOURCES = ../../asio.cpp \ +@SEPARATE_COMPILATION_TRUE@ $(am__append_1) +@SEPARATE_COMPILATION_TRUE@LDADD = libasio.a +AM_CXXFLAGS = -I$(srcdir)/../../../include +@HAVE_COROUTINES_TRUE@coroutines_ts_chat_server_SOURCES = coroutines_ts/chat_server.cpp +@HAVE_COROUTINES_TRUE@coroutines_ts_echo_server_SOURCES = coroutines_ts/echo_server.cpp +@HAVE_COROUTINES_TRUE@coroutines_ts_echo_server_with_default_SOURCES = coroutines_ts/echo_server_with_default.cpp +@HAVE_COROUTINES_TRUE@coroutines_ts_echo_server_with_as_single_default_SOURCES = coroutines_ts/echo_server_with_as_single_default.cpp +@HAVE_COROUTINES_TRUE@coroutines_ts_echo_server_with_as_tuple_default_SOURCES = coroutines_ts/echo_server_with_as_tuple_default.cpp +@HAVE_COROUTINES_TRUE@coroutines_ts_refactored_echo_server_SOURCES = coroutines_ts/refactored_echo_server.cpp +EXTRA_DIST = \ + coroutines_ts/range_based_for.cpp + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/examples/cpp17/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/examples/cpp17/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +../../$(am__dirstamp): + @$(MKDIR_P) ../.. + @: > ../../$(am__dirstamp) +../../$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) ../../$(DEPDIR) + @: > ../../$(DEPDIR)/$(am__dirstamp) +../../asio.$(OBJEXT): ../../$(am__dirstamp) \ + ../../$(DEPDIR)/$(am__dirstamp) +../../asio_ssl.$(OBJEXT): ../../$(am__dirstamp) \ + ../../$(DEPDIR)/$(am__dirstamp) + +libasio.a: $(libasio_a_OBJECTS) $(libasio_a_DEPENDENCIES) $(EXTRA_libasio_a_DEPENDENCIES) + $(AM_V_at)-rm -f libasio.a + $(AM_V_AR)$(libasio_a_AR) libasio.a $(libasio_a_OBJECTS) $(libasio_a_LIBADD) + $(AM_V_at)$(RANLIB) libasio.a +coroutines_ts/$(am__dirstamp): + @$(MKDIR_P) coroutines_ts + @: > coroutines_ts/$(am__dirstamp) +coroutines_ts/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) coroutines_ts/$(DEPDIR) + @: > coroutines_ts/$(DEPDIR)/$(am__dirstamp) +coroutines_ts/chat_server.$(OBJEXT): coroutines_ts/$(am__dirstamp) \ + coroutines_ts/$(DEPDIR)/$(am__dirstamp) + +coroutines_ts/chat_server$(EXEEXT): $(coroutines_ts_chat_server_OBJECTS) $(coroutines_ts_chat_server_DEPENDENCIES) $(EXTRA_coroutines_ts_chat_server_DEPENDENCIES) coroutines_ts/$(am__dirstamp) + @rm -f coroutines_ts/chat_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_ts_chat_server_OBJECTS) $(coroutines_ts_chat_server_LDADD) $(LIBS) +coroutines_ts/echo_server.$(OBJEXT): coroutines_ts/$(am__dirstamp) \ + coroutines_ts/$(DEPDIR)/$(am__dirstamp) + +coroutines_ts/echo_server$(EXEEXT): $(coroutines_ts_echo_server_OBJECTS) $(coroutines_ts_echo_server_DEPENDENCIES) $(EXTRA_coroutines_ts_echo_server_DEPENDENCIES) coroutines_ts/$(am__dirstamp) + @rm -f coroutines_ts/echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_ts_echo_server_OBJECTS) $(coroutines_ts_echo_server_LDADD) $(LIBS) +coroutines_ts/echo_server_with_as_single_default.$(OBJEXT): \ + coroutines_ts/$(am__dirstamp) \ + coroutines_ts/$(DEPDIR)/$(am__dirstamp) + +coroutines_ts/echo_server_with_as_single_default$(EXEEXT): $(coroutines_ts_echo_server_with_as_single_default_OBJECTS) $(coroutines_ts_echo_server_with_as_single_default_DEPENDENCIES) $(EXTRA_coroutines_ts_echo_server_with_as_single_default_DEPENDENCIES) coroutines_ts/$(am__dirstamp) + @rm -f coroutines_ts/echo_server_with_as_single_default$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_ts_echo_server_with_as_single_default_OBJECTS) $(coroutines_ts_echo_server_with_as_single_default_LDADD) $(LIBS) +coroutines_ts/echo_server_with_as_tuple_default.$(OBJEXT): \ + coroutines_ts/$(am__dirstamp) \ + coroutines_ts/$(DEPDIR)/$(am__dirstamp) + +coroutines_ts/echo_server_with_as_tuple_default$(EXEEXT): $(coroutines_ts_echo_server_with_as_tuple_default_OBJECTS) $(coroutines_ts_echo_server_with_as_tuple_default_DEPENDENCIES) $(EXTRA_coroutines_ts_echo_server_with_as_tuple_default_DEPENDENCIES) coroutines_ts/$(am__dirstamp) + @rm -f coroutines_ts/echo_server_with_as_tuple_default$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_ts_echo_server_with_as_tuple_default_OBJECTS) $(coroutines_ts_echo_server_with_as_tuple_default_LDADD) $(LIBS) +coroutines_ts/echo_server_with_default.$(OBJEXT): \ + coroutines_ts/$(am__dirstamp) \ + coroutines_ts/$(DEPDIR)/$(am__dirstamp) + +coroutines_ts/echo_server_with_default$(EXEEXT): $(coroutines_ts_echo_server_with_default_OBJECTS) $(coroutines_ts_echo_server_with_default_DEPENDENCIES) $(EXTRA_coroutines_ts_echo_server_with_default_DEPENDENCIES) coroutines_ts/$(am__dirstamp) + @rm -f coroutines_ts/echo_server_with_default$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_ts_echo_server_with_default_OBJECTS) $(coroutines_ts_echo_server_with_default_LDADD) $(LIBS) +coroutines_ts/refactored_echo_server.$(OBJEXT): \ + coroutines_ts/$(am__dirstamp) \ + coroutines_ts/$(DEPDIR)/$(am__dirstamp) + +coroutines_ts/refactored_echo_server$(EXEEXT): $(coroutines_ts_refactored_echo_server_OBJECTS) $(coroutines_ts_refactored_echo_server_DEPENDENCIES) $(EXTRA_coroutines_ts_refactored_echo_server_DEPENDENCIES) coroutines_ts/$(am__dirstamp) + @rm -f coroutines_ts/refactored_echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_ts_refactored_echo_server_OBJECTS) $(coroutines_ts_refactored_echo_server_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + -rm -f ../../*.$(OBJEXT) + -rm -f coroutines_ts/*.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@../../$(DEPDIR)/asio.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@../../$(DEPDIR)/asio_ssl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines_ts/$(DEPDIR)/chat_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines_ts/$(DEPDIR)/echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines_ts/$(DEPDIR)/echo_server_with_as_single_default.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines_ts/$(DEPDIR)/echo_server_with_as_tuple_default.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines_ts/$(DEPDIR)/echo_server_with_default.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines_ts/$(DEPDIR)/refactored_echo_server.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f ../../$(DEPDIR)/$(am__dirstamp) + -rm -f ../../$(am__dirstamp) + -rm -f coroutines_ts/$(DEPDIR)/$(am__dirstamp) + -rm -f coroutines_ts/$(am__dirstamp) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -f ../../$(DEPDIR)/asio.Po + -rm -f ../../$(DEPDIR)/asio_ssl.Po + -rm -f coroutines_ts/$(DEPDIR)/chat_server.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server_with_as_single_default.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server_with_as_tuple_default.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server_with_default.Po + -rm -f coroutines_ts/$(DEPDIR)/refactored_echo_server.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ../../$(DEPDIR)/asio.Po + -rm -f ../../$(DEPDIR)/asio_ssl.Po + -rm -f coroutines_ts/$(DEPDIR)/chat_server.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server_with_as_single_default.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server_with_as_tuple_default.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server_with_default.Po + -rm -f coroutines_ts/$(DEPDIR)/refactored_echo_server.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/chat_server.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/chat_server.cpp new file mode 100644 index 00000000000..cd5fba32486 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/chat_server.cpp @@ -0,0 +1,222 @@ +// +// chat_server.cpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <cstdlib> +#include <deque> +#include <iostream> +#include <list> +#include <memory> +#include <set> +#include <string> +#include <utility> +#include <asio/awaitable.hpp> +#include <asio/detached.hpp> +#include <asio/co_spawn.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/read_until.hpp> +#include <asio/redirect_error.hpp> +#include <asio/signal_set.hpp> +#include <asio/steady_timer.hpp> +#include <asio/use_awaitable.hpp> +#include <asio/write.hpp> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::redirect_error; +using asio::use_awaitable; + +//---------------------------------------------------------------------- + +class chat_participant +{ +public: + virtual ~chat_participant() {} + virtual void deliver(const std::string& msg) = 0; +}; + +typedef std::shared_ptr<chat_participant> chat_participant_ptr; + +//---------------------------------------------------------------------- + +class chat_room +{ +public: + void join(chat_participant_ptr participant) + { + participants_.insert(participant); + for (auto msg: recent_msgs_) + participant->deliver(msg); + } + + void leave(chat_participant_ptr participant) + { + participants_.erase(participant); + } + + void deliver(const std::string& msg) + { + recent_msgs_.push_back(msg); + while (recent_msgs_.size() > max_recent_msgs) + recent_msgs_.pop_front(); + + for (auto participant: participants_) + participant->deliver(msg); + } + +private: + std::set<chat_participant_ptr> participants_; + enum { max_recent_msgs = 100 }; + std::deque<std::string> recent_msgs_; +}; + +//---------------------------------------------------------------------- + +class chat_session + : public chat_participant, + public std::enable_shared_from_this<chat_session> +{ +public: + chat_session(tcp::socket socket, chat_room& room) + : socket_(std::move(socket)), + timer_(socket_.get_executor()), + room_(room) + { + timer_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + void start() + { + room_.join(shared_from_this()); + + co_spawn(socket_.get_executor(), + [self = shared_from_this()]{ return self->reader(); }, + detached); + + co_spawn(socket_.get_executor(), + [self = shared_from_this()]{ return self->writer(); }, + detached); + } + + void deliver(const std::string& msg) + { + write_msgs_.push_back(msg); + timer_.cancel_one(); + } + +private: + awaitable<void> reader() + { + try + { + for (std::string read_msg;;) + { + std::size_t n = co_await asio::async_read_until(socket_, + asio::dynamic_buffer(read_msg, 1024), "\n", use_awaitable); + + room_.deliver(read_msg.substr(0, n)); + read_msg.erase(0, n); + } + } + catch (std::exception&) + { + stop(); + } + } + + awaitable<void> writer() + { + try + { + while (socket_.is_open()) + { + if (write_msgs_.empty()) + { + asio::error_code ec; + co_await timer_.async_wait(redirect_error(use_awaitable, ec)); + } + else + { + co_await asio::async_write(socket_, + asio::buffer(write_msgs_.front()), use_awaitable); + write_msgs_.pop_front(); + } + } + } + catch (std::exception&) + { + stop(); + } + } + + void stop() + { + room_.leave(shared_from_this()); + socket_.close(); + timer_.cancel(); + } + + tcp::socket socket_; + asio::steady_timer timer_; + chat_room& room_; + std::deque<std::string> write_msgs_; +}; + +//---------------------------------------------------------------------- + +awaitable<void> listener(tcp::acceptor acceptor) +{ + chat_room room; + + for (;;) + { + std::make_shared<chat_session>( + co_await acceptor.async_accept(use_awaitable), + room + )->start(); + } +} + +//---------------------------------------------------------------------- + +int main(int argc, char* argv[]) +{ + try + { + if (argc < 2) + { + std::cerr << "Usage: chat_server <port> [<port> ...]\n"; + return 1; + } + + asio::io_context io_context(1); + + for (int i = 1; i < argc; ++i) + { + unsigned short port = std::atoi(argv[i]); + co_spawn(io_context, + listener(tcp::acceptor(io_context, {tcp::v4(), port})), + detached); + } + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server.cpp new file mode 100644 index 00000000000..a9532459f77 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server.cpp @@ -0,0 +1,76 @@ +// +// echo_server.cpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable; +namespace this_coro = asio::this_coro; + +#if defined(ASIO_ENABLE_HANDLER_TRACKING) +# define use_awaitable \ + asio::use_awaitable_t(__FILE__, __LINE__, __PRETTY_FUNCTION__) +#endif + +awaitable<void> echo(tcp::socket socket) +{ + try + { + char data[1024]; + for (;;) + { + std::size_t n = co_await socket.async_read_some(asio::buffer(data), use_awaitable); + co_await async_write(socket, asio::buffer(data, n), use_awaitable); + } + } + catch (std::exception& e) + { + std::printf("echo Exception: %s\n", e.what()); + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp::acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + tcp::socket socket = co_await acceptor.async_accept(use_awaitable); + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_as_single_default.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_as_single_default.cpp new file mode 100644 index 00000000000..4a692acc872 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_as_single_default.cpp @@ -0,0 +1,71 @@ +// +// echo_server_with_as_single_default.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/experimental/as_single.hpp> +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::experimental::as_single_t; +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable_t; +using default_token = as_single_t<use_awaitable_t<>>; +using tcp_acceptor = default_token::as_default_on_t<tcp::acceptor>; +using tcp_socket = default_token::as_default_on_t<tcp::socket>; +namespace this_coro = asio::this_coro; + +awaitable<void> echo(tcp_socket socket) +{ + char data[1024]; + for (;;) + { + auto [e1, nread] = co_await socket.async_read_some(asio::buffer(data)); + if (nread == 0) break; + auto [e2, nwritten] = co_await async_write(socket, asio::buffer(data, nread)); + if (nwritten != nread) break; + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp_acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + if (auto [e, socket] = co_await acceptor.async_accept(); socket.is_open()) + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_as_tuple_default.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_as_tuple_default.cpp new file mode 100644 index 00000000000..de162cad78e --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_as_tuple_default.cpp @@ -0,0 +1,71 @@ +// +// echo_server_with_as_tuple_default.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/as_tuple.hpp> +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::as_tuple_t; +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable_t; +using default_token = as_tuple_t<use_awaitable_t<>>; +using tcp_acceptor = default_token::as_default_on_t<tcp::acceptor>; +using tcp_socket = default_token::as_default_on_t<tcp::socket>; +namespace this_coro = asio::this_coro; + +awaitable<void> echo(tcp_socket socket) +{ + char data[1024]; + for (;;) + { + auto [e1, nread] = co_await socket.async_read_some(asio::buffer(data)); + if (nread == 0) break; + auto [e2, nwritten] = co_await async_write(socket, asio::buffer(data, nread)); + if (nwritten != nread) break; + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp_acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + if (auto [e, socket] = co_await acceptor.async_accept(); socket.is_open()) + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_default.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_default.cpp new file mode 100644 index 00000000000..54344d94d56 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_default.cpp @@ -0,0 +1,73 @@ +// +// echo_server_with_default.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable_t; +using tcp_acceptor = use_awaitable_t<>::as_default_on_t<tcp::acceptor>; +using tcp_socket = use_awaitable_t<>::as_default_on_t<tcp::socket>; +namespace this_coro = asio::this_coro; + +awaitable<void> echo(tcp_socket socket) +{ + try + { + char data[1024]; + for (;;) + { + std::size_t n = co_await socket.async_read_some(asio::buffer(data)); + co_await async_write(socket, asio::buffer(data, n)); + } + } + catch (std::exception& e) + { + std::printf("echo Exception: %s\n", e.what()); + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp_acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + auto socket = co_await acceptor.async_accept(); + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/range_based_for.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/range_based_for.cpp new file mode 100644 index 00000000000..599ed80cd3f --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/range_based_for.cpp @@ -0,0 +1,102 @@ +// +// range_based_for.cpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable; + +class connection_iter +{ + friend class connections; + tcp::acceptor* acceptor_ = nullptr; + tcp::socket socket_; + + connection_iter(tcp::acceptor& a, tcp::socket s) + : acceptor_(&a), socket_(std::move(s)) {} + +public: + tcp::socket operator*() + { + return std::move(socket_); + } + + awaitable<void> operator++() + { + socket_ = co_await acceptor_->async_accept(use_awaitable); + } + + bool operator==(const connection_iter&) const noexcept + { + return false; + } + + bool operator!=(const connection_iter&) const noexcept + { + return true; + } +}; + +class connections +{ + tcp::acceptor& acceptor_; + +public: + explicit connections(tcp::acceptor& a) : acceptor_(a) {} + + awaitable<connection_iter> begin() + { + tcp::socket s = co_await acceptor_.async_accept(use_awaitable); + co_return connection_iter(acceptor_, std::move(s)); + } + + connection_iter end() + { + return connection_iter(acceptor_, + tcp::socket(acceptor_.get_executor())); + } +}; + +awaitable<void> listener(tcp::acceptor acceptor) +{ + for co_await (tcp::socket s : connections(acceptor)) + { + co_await asio::async_write(s, asio::buffer("hello\r\n", 7), use_awaitable); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + co_spawn(io_context, listener(std::move(acceptor)), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/refactored_echo_server.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/refactored_echo_server.cpp new file mode 100644 index 00000000000..dc7b03d86e2 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/refactored_echo_server.cpp @@ -0,0 +1,80 @@ +// +// refactored_echo_server.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable; +namespace this_coro = asio::this_coro; + +awaitable<void> echo_once(tcp::socket& socket) +{ + char data[128]; + std::size_t n = co_await socket.async_read_some(asio::buffer(data), use_awaitable); + co_await async_write(socket, asio::buffer(data, n), use_awaitable); +} + +awaitable<void> echo(tcp::socket socket) +{ + try + { + for (;;) + { + // The asynchronous operations to echo a single chunk of data have been + // refactored into a separate function. When this function is called, the + // operations are still performed in the context of the current + // coroutine, and the behaviour is functionally equivalent. + co_await echo_once(socket); + } + } + catch (std::exception& e) + { + std::printf("echo Exception: %s\n", e.what()); + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp::acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + tcp::socket socket = co_await acceptor.async_accept(use_awaitable); + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} |