/
settings.hpp
1669 lines (1473 loc) · 38.6 KB
/
settings.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
restinio
*/
/*!
HTTP-Server configuration.
*/
#pragma once
#include <restinio/asio_include.hpp>
#include <restinio/exception.hpp>
#include <restinio/request_handler.hpp>
#include <restinio/traits.hpp>
#include <restinio/incoming_http_msg_limits.hpp>
#include <restinio/variant.hpp>
#include <chrono>
#include <tuple>
#include <utility>
namespace restinio
{
namespace details
{
//! Default instantiation for a specific type.
template < typename Object >
inline auto
create_default_unique_object_instance( std::false_type )
{
return std::unique_ptr< Object >{};
}
template < typename Object >
inline auto
create_default_unique_object_instance( std::true_type )
{
return std::make_unique< Object >();
}
//! Default instantiation for a specific type.
template < typename Object >
inline auto
create_default_shared_object_instance( std::false_type )
{
return std::shared_ptr< Object >{};
}
template < typename Object >
inline auto
create_default_shared_object_instance( std::true_type )
{
return std::make_shared< Object >();
}
} /* namespace details */
//
// create_default_unique_object_instance
//
//! Default instantiation for a specific type.
template < typename Object>
inline auto
create_default_unique_object_instance()
{
typename std::is_default_constructible< Object >::type tag;
return details::create_default_unique_object_instance< Object >( tag );
}
//! Default instantiation for default_request_handler_t.
template <>
inline auto
create_default_unique_object_instance< default_request_handler_t >()
{
return details::create_default_unique_object_instance< default_request_handler_t >(
std::false_type{} );
}
//
// create_default_shared_object_instance
//
//! Default instantiation for a specific type.
template < typename Object>
inline auto
create_default_shared_object_instance()
{
typename std::is_default_constructible< Object >::type tag;
return details::create_default_shared_object_instance< Object >( tag );
}
//! Default instantiation for default_request_handler_t.
template <>
inline auto
create_default_shared_object_instance< default_request_handler_t >()
{
return details::create_default_shared_object_instance< default_request_handler_t >(
std::false_type{} );
}
//
// ensure_created()
//
//! Ensure that object was created.
template < typename Object >
auto
ensure_created(
std::unique_ptr< Object > mb_created_one,
string_view_t fail_description )
{
if( !mb_created_one )
mb_created_one = create_default_unique_object_instance< Object >();
if( !mb_created_one )
throw exception_t{ fail_description };
return mb_created_one;
}
//
// unsure_created()
//
//! Ensure that object was created.
template < typename Object >
auto
ensure_created(
std::shared_ptr< Object > mb_created_one,
string_view_t fail_description )
{
if( !mb_created_one )
mb_created_one = create_default_shared_object_instance< Object >();
if( !mb_created_one )
throw exception_t{ fail_description };
return mb_created_one;
}
//
// socket_type_dependent_settings_t
//
//! Extra settings needed for working with socket.
template < typename Settings, typename Socket >
class socket_type_dependent_settings_t
{
protected :
~socket_type_dependent_settings_t() noexcept = default;
public :
socket_type_dependent_settings_t() noexcept = default;
socket_type_dependent_settings_t(const socket_type_dependent_settings_t &) noexcept = default;
socket_type_dependent_settings_t(socket_type_dependent_settings_t &&) noexcept = default;
socket_type_dependent_settings_t &
operator=(const socket_type_dependent_settings_t &) noexcept = default;
socket_type_dependent_settings_t &
operator=(socket_type_dependent_settings_t &&) noexcept = delete;
// No extra settings by default.
};
//
// acceptor_options_t
//
//! An adapter for setting acceptor options before running server.
/*!
Class hides an acceptor object and opens only set/get options API.
It is used as an argument for a user defined function-object
that can set custom options for acceptor.
*/
class acceptor_options_t
{
public:
acceptor_options_t( asio_ns::ip::tcp::acceptor & acceptor )
: m_acceptor{ acceptor }
{}
//! API for setting/getting options.
//! \{
template< typename Option >
void
set_option( const Option & option )
{
m_acceptor.set_option( option );
}
template< typename Option >
void
set_option( const Option & option, asio_ns::error_code & ec )
{
m_acceptor.set_option( option, ec );
}
template< typename Option >
void
get_option( Option & option )
{
m_acceptor.get_option( option );
}
template< typename Option >
void
get_option( Option & option, asio_ns::error_code & ec )
{
m_acceptor.get_option( option, ec );
}
//! \}
private:
asio_ns::ip::tcp::acceptor & m_acceptor;
};
using acceptor_options_setter_t = std::function< void ( acceptor_options_t & ) >;
template <>
inline auto
create_default_unique_object_instance< acceptor_options_setter_t >()
{
return std::make_unique< acceptor_options_setter_t >(
[]( acceptor_options_t & options ){
options.set_option( asio_ns::ip::tcp::acceptor::reuse_address( true ) );
} );
}
//
// socket_options_t
//
//! An adapter for setting acceptor options before running server.
/*!
Class hides a socket object and opens only set/get options API.
It is used as an argument for a user defined function-object
that can set custom options for socket.
*/
class socket_options_t
{
public:
socket_options_t(
//! A reference on the most base class with interface of setting options.
asio_ns::basic_socket< asio_ns::ip::tcp > & socket )
: m_socket{ socket }
{}
//! API for setting/getting options.
//! \{
template< typename Option >
void
set_option( const Option & option )
{
m_socket.set_option( option );
}
template< typename Option >
void
set_option( const Option & option, asio_ns::error_code & ec )
{
m_socket.set_option( option, ec );
}
template< typename Option >
void
get_option( Option & option )
{
m_socket.get_option( option );
}
template< typename Option >
void
get_option( Option & option, asio_ns::error_code & ec )
{
m_socket.get_option( option, ec );
}
//! \}
private:
//! A reference on the most base class with interface of setting options.
asio_ns::basic_socket< asio_ns::ip::tcp > & m_socket;
};
using socket_options_setter_t = std::function< void ( socket_options_t & ) >;
template <>
inline auto
create_default_unique_object_instance< socket_options_setter_t >()
{
return std::make_unique< socket_options_setter_t >( []( auto & ){} );
}
//
// cleanup_functor_t
//
/*!
* \brief Type of holder for user's cleanup function.
*/
using cleanup_functor_t = std::function< void(void) >;
//
// connection_state_listener_holder_t
//
/*!
* @brief A special class for holding actual connection state listener.
*
* This class holds shared pointer to actual connection state listener
* and provides an actual implementation of
* check_valid_connection_state_listener_pointer() method.
*
* @since v.0.5.1
*/
template< typename Listener >
struct connection_state_listener_holder_t
{
std::shared_ptr< Listener > m_connection_state_listener;
static constexpr bool has_actual_connection_state_listener = true;
//! Checks that pointer to state listener is not null.
/*!
* Throws an exception if m_connection_state_listener is nullptr.
*/
void
check_valid_connection_state_listener_pointer() const
{
if( !m_connection_state_listener )
throw exception_t{ "connection state listener is not specified" };
}
};
/*!
* @brief A special class for case when no-op state listener is used.
*
* Doesn't hold anything and contains empty
* check_valid_connection_state_listener_pointer() method.
*
* @since v.0.5.1
*/
template<>
struct connection_state_listener_holder_t< connection_state::noop_listener_t >
{
static constexpr bool has_actual_connection_state_listener = false;
void
check_valid_connection_state_listener_pointer() const
{
// Nothing to do.
}
};
//
// ip_blocker_holder_t
//
/*!
* @brief A special class for holding actual IP-blocker object.
*
* This class holds shared pointer to actual IP-blocker
* and provides an actual implementation of
* check_valid_ip_blocker_pointer() method.
*
* @since v.0.5.1
*/
template< typename Ip_Blocker >
struct ip_blocker_holder_t
{
static_assert(
noexcept( std::declval<Ip_Blocker>().inspect(
std::declval<ip_blocker::incoming_info_t>() ) ),
"Ip_Blocker::inspect() method should be noexcept" );
static_assert(
std::is_same<
restinio::ip_blocker::inspection_result_t,
decltype(std::declval<Ip_Blocker>().inspect(
std::declval<ip_blocker::incoming_info_t>())) >::value,
"Ip_Blocker::inspect() should return "
"restinio::ip_blocker::inspection_result_t" );
std::shared_ptr< Ip_Blocker > m_ip_blocker;
static constexpr bool has_actual_ip_blocker = true;
//! Checks that pointer to IP-blocker is not null.
/*!
* Throws an exception if m_ip_blocker is nullptr.
*/
void
check_valid_ip_blocker_pointer() const
{
if( !m_ip_blocker )
throw exception_t{ "IP-blocker is not specified" };
}
};
/*!
* @brief A special class for case when no-op IP-blocker is used.
*
* Doesn't hold anything and contains empty
* check_valid_ip_blocker_pointer() method.
*
* @since v.0.5.1
*/
template<>
struct ip_blocker_holder_t< ip_blocker::noop_ip_blocker_t >
{
static constexpr bool has_actual_ip_blocker = false;
void
check_valid_ip_blocker_pointer() const
{
// Nothing to do.
}
};
//
// acceptor_post_bind_hook_t
//
/*!
* @brief A type of callback to be called after a successful invocation
* of bind() function for the acceptor.
*
* @since v.0.6.11
*/
using acceptor_post_bind_hook_t = std::function<
void(asio_ns::ip::tcp::acceptor &) >;
namespace details
{
//
// no_address_specified_t
//
/*!
* @brief A special indicator for the case when IP address for a server
* is not set explicitly.
*
* @since v.0.6.11
*/
struct no_address_specified_t {};
//
// address_variant_t
//
/*!
* @brief A type of variant for holding IP address for a server in
* various representations.
*
* @since v.0.6.11
*/
using address_variant_t = variant_t<
no_address_specified_t,
std::string,
asio_ns::ip::address >;
//
// max_parallel_connections_holder_t
//
/*!
* @brief A special type for holding the value of maximum allowed
* count of parallel connections.
*
* This type is intended to be used as a mixin for
* server_settings_t type.
*
* Holds the value and provides the actual implementations for
* getter and setter of that value.
*
* @since v.0.6.12
*/
template< typename Count_Limiter >
struct max_parallel_connections_holder_t
{
static constexpr bool has_actual_max_parallel_connections = true;
/*!
* @brief Actual value of the limit.
*
* By the default the count of parallel connection is not limited.
*/
std::size_t m_max_parallel_connections{
std::numeric_limits<std::size_t>::max()
};
std::size_t
max_parallel_connections() const noexcept
{
return m_max_parallel_connections;
}
void
set_max_parallel_connections( std::size_t v ) noexcept
{
m_max_parallel_connections = v;
}
};
/*!
* @brief A specialization of max_parallel_connections_holder for the case
* when connection count isn't limited.
*
* Doesn't hold anything. Hasn't a setter.
*
* The getter returns a value that means that there is no connection
* count limit at all.
*
* @since v.0.6.12
*/
template<>
struct max_parallel_connections_holder_t<
::restinio::connection_count_limits::noop_connection_count_limiter_t >
{
static constexpr bool has_actual_max_parallel_connections = false;
std::size_t
max_parallel_connections() const noexcept
{
return std::numeric_limits<std::size_t>::max();
}
};
} /* namespace details */
//
// basic_server_settings_t
//
//! Basic container for http_server settings.
/*!
* It exists to provide ablity to create various derived classes
* like server_settings_t, run_on_this_thread_settings_t,
* run_on_this_thread_settings_t and so on.
*
* \tparam Derived A drived type. Reference to this derived type
* will be returned by setters.
*
* \tparam Traits A type with traits for http_server.
*/
template<typename Derived, typename Traits>
class basic_server_settings_t
: public socket_type_dependent_settings_t< Derived, typename Traits::stream_socket_t >
, protected connection_state_listener_holder_t<
typename Traits::connection_state_listener_t >
, protected ip_blocker_holder_t< typename Traits::ip_blocker_t >
, protected details::max_parallel_connections_holder_t<
typename connection_count_limit_types<Traits>::limiter_t >
{
using base_type_t = socket_type_dependent_settings_t<
Derived, typename Traits::stream_socket_t>;
using max_parallel_connections_holder_base_t =
details::max_parallel_connections_holder_t<
typename connection_count_limit_types<Traits>::limiter_t >;
using connection_state_listener_holder_t<
typename Traits::connection_state_listener_t
>::has_actual_connection_state_listener;
using ip_blocker_holder_t<
typename Traits::ip_blocker_t
>::has_actual_ip_blocker;
using max_parallel_connections_holder_base_t::has_actual_max_parallel_connections;
public:
basic_server_settings_t(
std::uint16_t port = 8080,
asio_ns::ip::tcp protocol = asio_ns::ip::tcp::v4() )
: base_type_t{}
, m_port{ port }
, m_protocol{ protocol }
{}
//! Server endpoint.
//! \{
Derived &
port( std::uint16_t p ) &
{
m_port = p;
return reference_to_derived();
}
Derived &&
port( std::uint16_t p ) &&
{
return std::move( this->port( p ) );
}
RESTINIO_NODISCARD
std::uint16_t
port() const
{
return m_port;
}
Derived &
protocol( asio_ns::ip::tcp p ) &
{
m_protocol = p;
return reference_to_derived();
}
Derived &&
protocol( asio_ns::ip::tcp p ) &&
{
return std::move( this->protocol( p ) );
}
RESTINIO_NODISCARD
asio_ns::ip::tcp
protocol() const
{
return m_protocol;
}
/*!
* Sets the IP address for a server in textual form.
*
* Usage example:
* @code
* using my_server_t = restinio::http_server_t< my_server_traits_t >;
* my_server_t server{
* restinio::own_io_context(),
* [](auto & settings) {
* settings.port(8080);
* settings.address("192.168.1.1");
* settings.request_handler(...);
* ...
* }
* };
* @endcode
*/
Derived &
address( std::string addr ) &
{
m_address = std::move(addr);
return reference_to_derived();
}
/*!
* Sets the IP address for a server in textual form.
*
* Usage example:
* @code
* restinio::run(
* restinio::on_this_thread()
* .port(...)
* .address("192.168.1.1")
* .request_handler(...)
* );
* @endcode
*/
Derived &&
address( std::string addr ) &&
{
return std::move( this->address( std::move( addr ) ) );
}
/*!
* Sets the IP address for a server in binary form.
*
* Usage example:
* @code
* auto actual_ip = asio::ip::address::from_string(app.config().ip_addr());
* ...
* using my_server_t = restinio::http_server_t< my_server_traits_t >;
* my_server_t server{
* restinio::own_io_context(),
* [actual_ip](auto & settings) {
* settings.port(8080);
* settings.address(actual_ip);
* settings.request_handler(...);
* ...
* }
* };
* @endcode
*/
Derived &
address( asio_ns::ip::address addr ) &
{
m_address = addr;
return reference_to_derived();
}
/*!
* Sets the IP address for a server in binary form.
*
* Usage example:
* @code
* auto actual_ip = asio::ip::address::from_string(app.config().ip_addr());
* ...
* restinio::run(
* restinio::on_this_thread()
* .port(...)
* .address(actual_ip)
* .request_handler(...)
* );
* @endcode
*/
Derived &&
address( asio_ns::ip::address addr ) &&
{
return std::move( this->address( addr ) );
}
RESTINIO_NODISCARD
const details::address_variant_t &
address() const
{
return m_address;
}
//! \}
//! Size of buffer for io operations.
/*!
It limits a size of chunk that can be read from socket in a single
read operattion (async read).
*/
//! {
Derived &
buffer_size( std::size_t s ) &
{
m_buffer_size = s;
return reference_to_derived();
}
Derived &&
buffer_size( std::size_t s ) &&
{
return std::move( this->buffer_size( s ) );
}
std::size_t
buffer_size() const
{
return m_buffer_size;
}
//! }
//! A period for holding connection before completely receiving
//! new http-request. Starts counting since connection is establised
//! or a previous request was responsed.
/*!
Generaly it defines timeout for keep-alive connections.
*/
//! \{
Derived &
read_next_http_message_timelimit( std::chrono::steady_clock::duration d ) &
{
m_read_next_http_message_timelimit = std::move( d );
return reference_to_derived();
}
Derived &&
read_next_http_message_timelimit( std::chrono::steady_clock::duration d ) &&
{
return std::move( this->read_next_http_message_timelimit( std::move( d ) ) );
}
std::chrono::steady_clock::duration
read_next_http_message_timelimit() const
{
return m_read_next_http_message_timelimit;
}
//! \}
//! A period of time wait for response to be written to socket.
//! \{
Derived &
write_http_response_timelimit( std::chrono::steady_clock::duration d ) &
{
m_write_http_response_timelimit = std::move( d );
return reference_to_derived();
}
Derived &&
write_http_response_timelimit( std::chrono::steady_clock::duration d ) &&
{
return std::move( this->write_http_response_timelimit( std::move( d ) ) );
}
std::chrono::steady_clock::duration
write_http_response_timelimit() const
{
return m_write_http_response_timelimit;
}
//! \}
//! A period of time that is given for a handler to create response.
//! \{
Derived &
handle_request_timeout( std::chrono::steady_clock::duration d ) &
{
m_handle_request_timeout = std::move( d );
return reference_to_derived();
}
Derived &&
handle_request_timeout( std::chrono::steady_clock::duration d ) &&
{
return std::move( this->handle_request_timeout( std::move( d ) ) );
}
std::chrono::steady_clock::duration
handle_request_timeout() const
{
return m_handle_request_timeout;
}
//! \}
//! Max pipelined requests able to receive on single connection.
//! \{
Derived &
max_pipelined_requests( std::size_t mpr ) &
{
m_max_pipelined_requests = mpr;
return reference_to_derived();
}
Derived &&
max_pipelined_requests( std::size_t mpr ) &&
{
return std::move( this->max_pipelined_requests( mpr ) );
}
std::size_t
max_pipelined_requests() const
{
return m_max_pipelined_requests;
}
//! \}
//! Request handler.
//! \{
using request_handler_t = typename Traits::request_handler_t;
Derived &
request_handler( std::unique_ptr< request_handler_t > handler ) &
{
m_request_handler = std::move( handler );
return reference_to_derived();
}
template< typename... Params >
Derived &
request_handler( Params &&... params ) &
{
return set_unique_instance(
m_request_handler,
std::forward< Params >( params )... );
}
template< typename... Params >
Derived &&
request_handler( Params &&... params ) &&
{
return std::move( this->request_handler( std::forward< Params >( params )... ) );
}
std::unique_ptr< request_handler_t >
request_handler()
{
return ensure_created(
std::move( m_request_handler ),
"request handler must be set" );
}
//! \}
//! Timers manager.
//! \{
using timer_manager_t = typename Traits::timer_manager_t;
using timer_factory_t = typename timer_manager_t::factory_t;
template< typename... Params >
Derived &
timer_manager( Params &&... params ) &
{
return set_unique_instance(
m_timer_factory,
std::forward< Params >( params )... );
}
template< typename... Params >
Derived &&
timer_manager( Params &&... params ) &&
{
return std::move( this->timer_manager( std::forward< Params >( params )... ) );
}
std::unique_ptr< timer_factory_t >
timer_factory()
{
return ensure_created(
std::move( m_timer_factory ),
"timer manager is not set" );
}
//! \}
//! Logger.
//! \{
using logger_t = typename Traits::logger_t;
template< typename... Params >
Derived &
logger( Params &&... params ) &
{
return set_unique_instance(
m_logger,
std::forward< Params >( params )... );
}
template< typename... Params >
Derived &&
logger( Params &&... params ) &&
{
return std::move( this->logger( std::forward< Params >( params )... ) );
}
std::unique_ptr< logger_t >
logger()
{
return ensure_created(
std::move( m_logger ),
"logger must be set" );
}
//! \}
//! Acceptor options setter.
//! \{
Derived &
acceptor_options_setter( acceptor_options_setter_t aos ) &
{
if( !aos )
throw exception_t{ "acceptor options setter cannot be empty" };
return set_unique_instance(
m_acceptor_options_setter,
std::move( aos ) );
}
Derived &&
acceptor_options_setter( acceptor_options_setter_t aos ) &&
{
return std::move( this->acceptor_options_setter( std::move( aos ) ) );
}
std::unique_ptr< acceptor_options_setter_t >
acceptor_options_setter()
{
return ensure_created(
std::move( m_acceptor_options_setter ),
"acceptor options setter must be set" );
}
//! \}
//! Socket options setter.
//! \{
Derived &
socket_options_setter( socket_options_setter_t sos ) &
{
if( !sos )
throw exception_t{ "socket options setter cannot be empty" };
return set_unique_instance(
m_socket_options_setter,
std::move( sos ) );
}
Derived &&
socket_options_setter( socket_options_setter_t sos ) &&
{
return std::move( this->socket_options_setter( std::move( sos ) ) );
}
std::unique_ptr< socket_options_setter_t >
socket_options_setter()
{
return ensure_created(
std::move( m_socket_options_setter ),
"socket options setter must be set" );
}
//! \}
//! Max number of running concurrent accepts.
/*!
When running server on N threads
then up to N accepts can be handled concurrently.
*/