├── .gitignore ├── .travis.yml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── atari ├── .gitignore ├── CMakeLists.txt ├── README.md ├── atari_game.cc ├── atari_game.h ├── atari_game_specific.h ├── benchmark-ale.cpp ├── benchmark-atari.cpp ├── benchmark-atari.py ├── benchmark-gym.py ├── game.py ├── game_context.h ├── model.py ├── python_wrapper.cc └── timer.hh ├── check.py ├── console_df.sh ├── console_df_check_train.sh ├── console_df_mcts.sh ├── df_console.py ├── df_selfplay.py ├── df_selfplay.sh ├── docs ├── .gitignore ├── Makefile └── source │ ├── RTS-engine.rst │ ├── conf.py │ ├── imgs │ └── hierarchy.png │ ├── index.rst │ ├── methods.rst │ ├── rlpytorch.rst │ ├── runner.rst │ ├── sampler.rst │ ├── stats.rst │ ├── trainer.rst │ ├── utils.rst │ ├── wrapper-python.rst │ └── wrapper.rst ├── elf ├── CMakeLists.txt ├── __init__.py ├── ai.h ├── ai_comm.h ├── circular_queue.h ├── collector.hh ├── comm_template.h ├── common.h ├── compile_test_mcts.sh ├── context_utils.py ├── copier.hh ├── ctpl_stl.h ├── game_base.h ├── hist.h ├── lib │ ├── debugutils.cc │ ├── debugutils.hh │ ├── strutils.cc │ └── strutils.hh ├── mcts.h ├── member_check.h ├── more_labels.py ├── primitive.h ├── pybind_helper.h ├── pybind_interface.h ├── python_options_utils_cpp.h ├── replay_loader.cc ├── replay_loader.h ├── shared_buffer.hh ├── shared_replay_buffer.h ├── signal.h ├── state_collector.h ├── stats.h ├── tar_loader.cc ├── tar_loader.h ├── test_tree_search.cc ├── tree_search.h ├── tree_search_alg.h ├── tree_search_base.h ├── tree_search_node.h ├── tree_search_options.h ├── utils.h └── utils_elf.py ├── elf_python ├── GCWrapper.py ├── README.md ├── __init__.py ├── assembler.py ├── circular_queue.py ├── memory_receiver.py ├── offline_assembler.py ├── replier.py ├── simulator.py ├── utils.py └── zmq_adapter.py ├── eval.py ├── eval_atari.sh ├── eval_checkforward.py ├── eval_lstm.py ├── eval_minirts.sh ├── eval_minirts2.sh ├── eval_reduced_mcts.py ├── eval_selfplay_aivsai.py ├── ex_elfpy.py ├── go ├── CMakeLists.txt ├── README.md ├── ai.h ├── board.cc ├── board.h ├── board_feature.cc ├── board_feature.h ├── common.cc ├── common.h ├── df_model.py ├── df_model2.py ├── game.cc ├── game.h ├── game.py ├── game_context.h ├── go_ai.h ├── go_game_specific.h ├── go_state.cc ├── go_state.h ├── mcts.h ├── multiple_prediction.py ├── offpolicy_loader.cc ├── offpolicy_loader.h ├── python_wrapper.cc ├── sample1.sgf ├── sgf.cc ├── sgf.h ├── test_sgf.cc └── train.lst ├── overview.png ├── rlpytorch ├── README.md ├── __init__.py ├── args_provider.py ├── args_utils.py ├── methods │ ├── __init__.py │ ├── actor_critic.py │ ├── discounted_reward.py │ ├── policy_gradient.py │ ├── q_learning.py │ ├── rnn_actor_critic.py │ ├── utils.py │ └── value_matcher.py ├── model_base.py ├── model_interface.py ├── model_loader.py ├── runner │ ├── __init__.py │ ├── eval_iters.py │ ├── multi_process.py │ ├── parameter_server.py │ └── single_process.py ├── sampler │ ├── __init__.py │ ├── sample_methods.py │ └── sampler.py ├── stats │ ├── __init__.py │ └── stats.py ├── trainer │ ├── __init__.py │ ├── lstm_trainer.py │ ├── timer.py │ ├── trainer.py │ └── utils.py └── utils │ ├── __init__.py │ ├── hist_states.py │ ├── size_utils.py │ └── utils.py ├── rts ├── .gitignore ├── CMakeLists.txt ├── README.md ├── __init__.py ├── backend │ ├── CMakeLists.txt │ ├── README.md │ ├── comm_ai.cc │ ├── comm_ai.h │ ├── main_loop.cc │ ├── raw2cmd.cc │ ├── raw2cmd.h │ ├── save2json.cc │ └── save2json.h ├── engine │ ├── .ropeproject │ │ ├── config.py │ │ ├── globalnames │ │ ├── history │ │ └── objectdb │ ├── CMakeLists.txt │ ├── README.md │ ├── __init__.py │ ├── ai.cc │ ├── ai.h │ ├── bullet.cc │ ├── bullet.h │ ├── cmd.cc │ ├── cmd.def │ ├── cmd.h │ ├── cmd_interface.h │ ├── cmd_receiver.cc │ ├── cmd_receiver.h │ ├── cmd_specific.cc │ ├── cmd_specific.def │ ├── cmd_util.cc │ ├── cmd_util.h │ ├── common.h │ ├── common_loader.py │ ├── compile_cmds.py │ ├── custom_enum.h │ ├── game.cc │ ├── game.h │ ├── game_action.h │ ├── game_env.cc │ ├── game_env.h │ ├── game_new.h │ ├── game_options.h │ ├── game_state.cc │ ├── game_state.h │ ├── game_stats.h │ ├── gamedef.cc │ ├── gamedef.h │ ├── locality_search.h │ ├── map.cc │ ├── map.h │ ├── player.cc │ ├── player.h │ ├── pq_extend.h │ ├── python_common_options.h │ ├── replay_loader.cc │ ├── replay_loader.h │ ├── rule_actor.cc │ ├── rule_actor.h │ ├── serializer.h │ ├── ui_cmd.h │ ├── unit.cc │ ├── unit.h │ └── wrapper_template.h ├── frontend │ ├── game.js │ ├── imgs │ │ ├── 14SAF.png │ │ ├── 2ebyiko.png │ │ ├── 2eki549.png │ │ ├── Actor1_zps2890a1cd.png │ │ ├── Actor2.png │ │ ├── Christmas.png │ │ ├── People3.png │ │ ├── People4.png │ │ ├── RTPkaihenn18.png │ │ ├── Spacece.png │ │ ├── Sprites-Lunarea.png │ │ ├── barracks.png │ │ ├── base.png │ │ ├── building.png │ │ ├── char_sample_zpsef814b4c.png │ │ ├── items.png │ │ ├── items_12.png │ │ ├── mineral1.png │ │ └── tiles.png │ └── minirts.html ├── game_CF │ ├── CMakeLists.txt │ ├── ai.cc │ ├── ai.h │ ├── cf_rule_actor.cc │ ├── cf_rule_actor.h │ ├── cmd_specific.cc │ ├── cmd_specific.def │ ├── game.py │ ├── gamedef.cc │ ├── model.py │ ├── python_options.h │ ├── python_wrapper.cc │ ├── wrapper_callback.cc │ └── wrapper_callback.h ├── game_MC │ ├── CMakeLists.txt │ ├── __init__.py │ ├── actor_critic_changed.py │ ├── ai.cc │ ├── ai.h │ ├── cmd_specific.cc │ ├── cmd_specific.def │ ├── collect_rep_stats.py │ ├── forward_predict.py │ ├── game.py │ ├── game_action.cc │ ├── game_action.h │ ├── gamedef.cc │ ├── mc_rule_actor.cc │ ├── mc_rule_actor.h │ ├── mcts.h │ ├── mixed_ai.h │ ├── model.py │ ├── model_lstm.py │ ├── model_unit_cmd.py │ ├── python_options.h │ ├── python_wrapper.cc │ ├── reduced_ai.h │ ├── rule_ai.h │ ├── state_feature.cc │ ├── state_feature.h │ ├── trainable_ai.cc │ ├── trainable_ai.h │ ├── trunk.py │ ├── wrapper_callback.cc │ └── wrapper_callback.h ├── game_TD │ ├── CMakeLists.txt │ ├── ai.cc │ ├── ai.h │ ├── cmd_specific.cc │ ├── cmd_specific.def │ ├── game.py │ ├── gamedef.cc │ ├── model.py │ ├── python_options.h │ ├── python_wrapper.cc │ ├── td_rule_actor.cc │ ├── td_rule_actor.h │ ├── wrapper_callback.cc │ └── wrapper_callback.h └── rts_intro.png ├── selfplay.py ├── selfplay_aivsai.sh ├── selfplay_minirts.sh ├── train.py ├── train_atari.sh ├── train_df.sh ├── train_lstm.py ├── train_minirts.sh ├── train_minirts_unitcmd.sh └── vendor ├── CMakeLists.txt ├── LICENSE-asio ├── LICENSE-concurrentqueue.md ├── LICENSE-json.MIT ├── LICENSE-websocketpp ├── asio.hpp ├── asio ├── async_result.hpp ├── basic_datagram_socket.hpp ├── basic_deadline_timer.hpp ├── basic_io_object.hpp ├── basic_raw_socket.hpp ├── basic_seq_packet_socket.hpp ├── basic_serial_port.hpp ├── basic_signal_set.hpp ├── basic_socket.hpp ├── basic_socket_acceptor.hpp ├── basic_socket_iostream.hpp ├── basic_socket_streambuf.hpp ├── basic_stream_socket.hpp ├── basic_streambuf.hpp ├── basic_streambuf_fwd.hpp ├── basic_waitable_timer.hpp ├── buffer.hpp ├── buffered_read_stream.hpp ├── buffered_read_stream_fwd.hpp ├── buffered_stream.hpp ├── buffered_stream_fwd.hpp ├── buffered_write_stream.hpp ├── buffered_write_stream_fwd.hpp ├── buffers_iterator.hpp ├── completion_condition.hpp ├── connect.hpp ├── coroutine.hpp ├── datagram_socket_service.hpp ├── deadline_timer.hpp ├── deadline_timer_service.hpp ├── detail │ ├── addressof.hpp │ ├── array.hpp │ ├── array_fwd.hpp │ ├── assert.hpp │ ├── atomic_count.hpp │ ├── base_from_completion_cond.hpp │ ├── bind_handler.hpp │ ├── buffer_resize_guard.hpp │ ├── buffer_sequence_adapter.hpp │ ├── buffered_stream_storage.hpp │ ├── call_stack.hpp │ ├── chrono_time_traits.hpp │ ├── completion_handler.hpp │ ├── config.hpp │ ├── consuming_buffers.hpp │ ├── cstdint.hpp │ ├── date_time_fwd.hpp │ ├── deadline_timer_service.hpp │ ├── dependent_type.hpp │ ├── descriptor_ops.hpp │ ├── descriptor_read_op.hpp │ ├── descriptor_write_op.hpp │ ├── dev_poll_reactor.hpp │ ├── epoll_reactor.hpp │ ├── event.hpp │ ├── eventfd_select_interrupter.hpp │ ├── fd_set_adapter.hpp │ ├── fenced_block.hpp │ ├── function.hpp │ ├── gcc_arm_fenced_block.hpp │ ├── gcc_hppa_fenced_block.hpp │ ├── gcc_sync_fenced_block.hpp │ ├── gcc_x86_fenced_block.hpp │ ├── handler_alloc_helpers.hpp │ ├── handler_cont_helpers.hpp │ ├── handler_invoke_helpers.hpp │ ├── handler_tracking.hpp │ ├── handler_type_requirements.hpp │ ├── hash_map.hpp │ ├── impl │ │ ├── buffer_sequence_adapter.ipp │ │ ├── descriptor_ops.ipp │ │ ├── dev_poll_reactor.hpp │ │ ├── dev_poll_reactor.ipp │ │ ├── epoll_reactor.hpp │ │ ├── epoll_reactor.ipp │ │ ├── eventfd_select_interrupter.ipp │ │ ├── handler_tracking.ipp │ │ ├── kqueue_reactor.hpp │ │ ├── kqueue_reactor.ipp │ │ ├── pipe_select_interrupter.ipp │ │ ├── posix_event.ipp │ │ ├── posix_mutex.ipp │ │ ├── posix_thread.ipp │ │ ├── posix_tss_ptr.ipp │ │ ├── reactive_descriptor_service.ipp │ │ ├── reactive_serial_port_service.ipp │ │ ├── reactive_socket_service_base.ipp │ │ ├── resolver_service_base.ipp │ │ ├── select_reactor.hpp │ │ ├── select_reactor.ipp │ │ ├── service_registry.hpp │ │ ├── service_registry.ipp │ │ ├── signal_set_service.ipp │ │ ├── socket_ops.ipp │ │ ├── socket_select_interrupter.ipp │ │ ├── strand_service.hpp │ │ ├── strand_service.ipp │ │ ├── task_io_service.hpp │ │ ├── task_io_service.ipp │ │ ├── throw_error.ipp │ │ ├── timer_queue_ptime.ipp │ │ ├── timer_queue_set.ipp │ │ ├── win_event.ipp │ │ ├── win_iocp_handle_service.ipp │ │ ├── win_iocp_io_service.hpp │ │ ├── win_iocp_io_service.ipp │ │ ├── win_iocp_serial_port_service.ipp │ │ ├── win_iocp_socket_service_base.ipp │ │ ├── win_mutex.ipp │ │ ├── win_object_handle_service.ipp │ │ ├── win_static_mutex.ipp │ │ ├── win_thread.ipp │ │ ├── win_tss_ptr.ipp │ │ ├── winrt_ssocket_service_base.ipp │ │ ├── winrt_timer_scheduler.hpp │ │ ├── winrt_timer_scheduler.ipp │ │ └── winsock_init.ipp │ ├── io_control.hpp │ ├── keyword_tss_ptr.hpp │ ├── kqueue_reactor.hpp │ ├── limits.hpp │ ├── local_free_on_block_exit.hpp │ ├── macos_fenced_block.hpp │ ├── mutex.hpp │ ├── noncopyable.hpp │ ├── null_event.hpp │ ├── null_fenced_block.hpp │ ├── null_mutex.hpp │ ├── null_reactor.hpp │ ├── null_signal_blocker.hpp │ ├── null_socket_service.hpp │ ├── null_static_mutex.hpp │ ├── null_thread.hpp │ ├── null_tss_ptr.hpp │ ├── object_pool.hpp │ ├── old_win_sdk_compat.hpp │ ├── op_queue.hpp │ ├── operation.hpp │ ├── pipe_select_interrupter.hpp │ ├── pop_options.hpp │ ├── posix_event.hpp │ ├── posix_fd_set_adapter.hpp │ ├── posix_mutex.hpp │ ├── posix_signal_blocker.hpp │ ├── posix_static_mutex.hpp │ ├── posix_thread.hpp │ ├── posix_tss_ptr.hpp │ ├── push_options.hpp │ ├── reactive_descriptor_service.hpp │ ├── reactive_null_buffers_op.hpp │ ├── reactive_serial_port_service.hpp │ ├── reactive_socket_accept_op.hpp │ ├── reactive_socket_connect_op.hpp │ ├── reactive_socket_recv_op.hpp │ ├── reactive_socket_recvfrom_op.hpp │ ├── reactive_socket_recvmsg_op.hpp │ ├── reactive_socket_send_op.hpp │ ├── reactive_socket_sendto_op.hpp │ ├── reactive_socket_service.hpp │ ├── reactive_socket_service_base.hpp │ ├── reactor.hpp │ ├── reactor_fwd.hpp │ ├── reactor_op.hpp │ ├── reactor_op_queue.hpp │ ├── regex_fwd.hpp │ ├── resolve_endpoint_op.hpp │ ├── resolve_op.hpp │ ├── resolver_service.hpp │ ├── resolver_service_base.hpp │ ├── scoped_lock.hpp │ ├── scoped_ptr.hpp │ ├── select_interrupter.hpp │ ├── select_reactor.hpp │ ├── service_registry.hpp │ ├── shared_ptr.hpp │ ├── signal_blocker.hpp │ ├── signal_handler.hpp │ ├── signal_init.hpp │ ├── signal_op.hpp │ ├── signal_set_service.hpp │ ├── socket_holder.hpp │ ├── socket_ops.hpp │ ├── socket_option.hpp │ ├── socket_select_interrupter.hpp │ ├── socket_types.hpp │ ├── solaris_fenced_block.hpp │ ├── static_mutex.hpp │ ├── std_event.hpp │ ├── std_mutex.hpp │ ├── std_static_mutex.hpp │ ├── std_thread.hpp │ ├── strand_service.hpp │ ├── task_io_service.hpp │ ├── task_io_service_operation.hpp │ ├── task_io_service_thread_info.hpp │ ├── thread.hpp │ ├── thread_info_base.hpp │ ├── throw_error.hpp │ ├── throw_exception.hpp │ ├── timer_queue.hpp │ ├── timer_queue_base.hpp │ ├── timer_queue_ptime.hpp │ ├── timer_queue_set.hpp │ ├── timer_scheduler.hpp │ ├── timer_scheduler_fwd.hpp │ ├── tss_ptr.hpp │ ├── type_traits.hpp │ ├── variadic_templates.hpp │ ├── wait_handler.hpp │ ├── wait_op.hpp │ ├── weak_ptr.hpp │ ├── win_event.hpp │ ├── win_fd_set_adapter.hpp │ ├── win_fenced_block.hpp │ ├── win_iocp_handle_read_op.hpp │ ├── win_iocp_handle_service.hpp │ ├── win_iocp_handle_write_op.hpp │ ├── win_iocp_io_service.hpp │ ├── win_iocp_null_buffers_op.hpp │ ├── win_iocp_operation.hpp │ ├── win_iocp_overlapped_op.hpp │ ├── win_iocp_overlapped_ptr.hpp │ ├── win_iocp_serial_port_service.hpp │ ├── win_iocp_socket_accept_op.hpp │ ├── win_iocp_socket_connect_op.hpp │ ├── win_iocp_socket_recv_op.hpp │ ├── win_iocp_socket_recvfrom_op.hpp │ ├── win_iocp_socket_recvmsg_op.hpp │ ├── win_iocp_socket_send_op.hpp │ ├── win_iocp_socket_service.hpp │ ├── win_iocp_socket_service_base.hpp │ ├── win_iocp_thread_info.hpp │ ├── win_mutex.hpp │ ├── win_object_handle_service.hpp │ ├── win_static_mutex.hpp │ ├── win_thread.hpp │ ├── win_tss_ptr.hpp │ ├── winapi_thread.hpp │ ├── winrt_async_manager.hpp │ ├── winrt_async_op.hpp │ ├── winrt_resolve_op.hpp │ ├── winrt_resolver_service.hpp │ ├── winrt_socket_connect_op.hpp │ ├── winrt_socket_recv_op.hpp │ ├── winrt_socket_send_op.hpp │ ├── winrt_ssocket_service.hpp │ ├── winrt_ssocket_service_base.hpp │ ├── winrt_timer_scheduler.hpp │ ├── winrt_utils.hpp │ ├── winsock_init.hpp │ └── wrapped_handler.hpp ├── error.hpp ├── error_code.hpp ├── generic │ ├── basic_endpoint.hpp │ ├── datagram_protocol.hpp │ ├── detail │ │ ├── endpoint.hpp │ │ └── impl │ │ │ └── endpoint.ipp │ ├── raw_protocol.hpp │ ├── seq_packet_protocol.hpp │ └── stream_protocol.hpp ├── handler_alloc_hook.hpp ├── handler_continuation_hook.hpp ├── handler_invoke_hook.hpp ├── handler_type.hpp ├── high_resolution_timer.hpp ├── impl │ ├── buffered_read_stream.hpp │ ├── buffered_write_stream.hpp │ ├── connect.hpp │ ├── error.ipp │ ├── error_code.ipp │ ├── handler_alloc_hook.ipp │ ├── io_service.hpp │ ├── io_service.ipp │ ├── read.hpp │ ├── read_at.hpp │ ├── read_until.hpp │ ├── serial_port_base.hpp │ ├── serial_port_base.ipp │ ├── spawn.hpp │ ├── src.cpp │ ├── src.hpp │ ├── use_future.hpp │ ├── write.hpp │ └── write_at.hpp ├── io_service.hpp ├── ip │ ├── address.hpp │ ├── address_v4.hpp │ ├── address_v6.hpp │ ├── basic_endpoint.hpp │ ├── basic_resolver.hpp │ ├── basic_resolver_entry.hpp │ ├── basic_resolver_iterator.hpp │ ├── basic_resolver_query.hpp │ ├── detail │ │ ├── endpoint.hpp │ │ ├── impl │ │ │ └── endpoint.ipp │ │ └── socket_option.hpp │ ├── host_name.hpp │ ├── icmp.hpp │ ├── impl │ │ ├── address.hpp │ │ ├── address.ipp │ │ ├── address_v4.hpp │ │ ├── address_v4.ipp │ │ ├── address_v6.hpp │ │ ├── address_v6.ipp │ │ ├── basic_endpoint.hpp │ │ └── host_name.ipp │ ├── multicast.hpp │ ├── resolver_query_base.hpp │ ├── resolver_service.hpp │ ├── tcp.hpp │ ├── udp.hpp │ ├── unicast.hpp │ └── v6_only.hpp ├── is_read_buffered.hpp ├── is_write_buffered.hpp ├── local │ ├── basic_endpoint.hpp │ ├── connect_pair.hpp │ ├── datagram_protocol.hpp │ ├── detail │ │ ├── endpoint.hpp │ │ └── impl │ │ │ └── endpoint.ipp │ └── stream_protocol.hpp ├── placeholders.hpp ├── posix │ ├── basic_descriptor.hpp │ ├── basic_stream_descriptor.hpp │ ├── descriptor_base.hpp │ ├── stream_descriptor.hpp │ └── stream_descriptor_service.hpp ├── raw_socket_service.hpp ├── read.hpp ├── read_at.hpp ├── read_until.hpp ├── seq_packet_socket_service.hpp ├── serial_port.hpp ├── serial_port_base.hpp ├── serial_port_service.hpp ├── signal_set.hpp ├── signal_set_service.hpp ├── socket_acceptor_service.hpp ├── socket_base.hpp ├── spawn.hpp ├── ssl.hpp ├── steady_timer.hpp ├── strand.hpp ├── stream_socket_service.hpp ├── streambuf.hpp ├── system_error.hpp ├── system_timer.hpp ├── thread.hpp ├── time_traits.hpp ├── unyield.hpp ├── use_future.hpp ├── version.hpp ├── wait_traits.hpp ├── waitable_timer_service.hpp ├── windows │ ├── basic_handle.hpp │ ├── basic_object_handle.hpp │ ├── basic_random_access_handle.hpp │ ├── basic_stream_handle.hpp │ ├── object_handle.hpp │ ├── object_handle_service.hpp │ ├── overlapped_ptr.hpp │ ├── random_access_handle.hpp │ ├── random_access_handle_service.hpp │ ├── stream_handle.hpp │ └── stream_handle_service.hpp ├── write.hpp ├── write_at.hpp └── yield.hpp ├── blockingconcurrentqueue.h ├── concurrentqueue.h ├── json.hpp ├── microtar.c ├── microtar.h ├── pybind11 ├── .appveyor.yml ├── .gitignore ├── .gitmodules ├── .readthedocs.yml ├── .travis.yml ├── CMakeLists.txt ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── LICENSE ├── MANIFEST.in ├── README.md ├── include │ └── pybind11 │ │ ├── attr.h │ │ ├── buffer_info.h │ │ ├── cast.h │ │ ├── chrono.h │ │ ├── common.h │ │ ├── complex.h │ │ ├── detail │ │ ├── class.h │ │ ├── common.h │ │ ├── descr.h │ │ ├── init.h │ │ ├── internals.h │ │ └── typeid.h │ │ ├── eigen.h │ │ ├── embed.h │ │ ├── eval.h │ │ ├── functional.h │ │ ├── iostream.h │ │ ├── numpy.h │ │ ├── operators.h │ │ ├── options.h │ │ ├── pybind11.h │ │ ├── pytypes.h │ │ ├── stl.h │ │ └── stl_bind.h ├── pybind11 │ ├── __init__.py │ ├── __main__.py │ └── _version.py ├── setup.cfg ├── setup.py └── tools │ ├── FindCatch.cmake │ ├── FindEigen3.cmake │ ├── FindPythonLibsNew.cmake │ ├── check-style.sh │ ├── clang │ ├── .gitignore │ ├── LICENSE.TXT │ ├── README.md │ ├── __init__.py │ ├── cindex.py │ └── enumerations.py │ ├── libsize.py │ ├── mkdoc.py │ ├── pybind11Config.cmake.in │ └── pybind11Tools.cmake ├── websocketpp ├── CMakeFiles │ ├── CMakeDirectoryInformation.cmake │ └── progress.marks ├── CMakeLists.txt ├── CTestTestfile.cmake ├── Makefile ├── base64 │ └── base64.hpp ├── client.hpp ├── close.hpp ├── cmake_install.cmake ├── common │ ├── asio.hpp │ ├── asio_ssl.hpp │ ├── chrono.hpp │ ├── connection_hdl.hpp │ ├── cpp11.hpp │ ├── functional.hpp │ ├── md5.hpp │ ├── memory.hpp │ ├── network.hpp │ ├── platforms.hpp │ ├── random.hpp │ ├── regex.hpp │ ├── stdint.hpp │ ├── system_error.hpp │ ├── thread.hpp │ ├── time.hpp │ └── type_traits.hpp ├── concurrency │ ├── basic.hpp │ └── none.hpp ├── config │ ├── asio.hpp │ ├── asio_client.hpp │ ├── asio_no_tls.hpp │ ├── asio_no_tls_client.hpp │ ├── boost_config.hpp │ ├── core.hpp │ ├── core_client.hpp │ ├── debug.hpp │ ├── debug_asio.hpp │ ├── debug_asio_no_tls.hpp │ ├── minimal_client.hpp │ └── minimal_server.hpp ├── connection.hpp ├── connection_base.hpp ├── endpoint.hpp ├── endpoint_base.hpp ├── error.hpp ├── extensions │ ├── extension.hpp │ └── permessage_deflate │ │ ├── disabled.hpp │ │ └── enabled.hpp ├── frame.hpp ├── http │ ├── constants.hpp │ ├── impl │ │ ├── parser.hpp │ │ ├── request.hpp │ │ └── response.hpp │ ├── parser.hpp │ ├── request.hpp │ └── response.hpp ├── impl │ ├── connection_impl.hpp │ ├── endpoint_impl.hpp │ └── utilities_impl.hpp ├── logger │ ├── basic.hpp │ ├── levels.hpp │ ├── stub.hpp │ └── syslog.hpp ├── message_buffer │ ├── alloc.hpp │ ├── message.hpp │ └── pool.hpp ├── processors │ ├── base.hpp │ ├── hybi00.hpp │ ├── hybi07.hpp │ ├── hybi08.hpp │ ├── hybi13.hpp │ └── processor.hpp ├── random │ ├── none.hpp │ └── random_device.hpp ├── roles │ ├── client_endpoint.hpp │ └── server_endpoint.hpp ├── server.hpp ├── sha1 │ └── sha1.hpp ├── transport │ ├── asio │ │ ├── base.hpp │ │ ├── connection.hpp │ │ ├── endpoint.hpp │ │ └── security │ │ │ ├── base.hpp │ │ │ ├── none.hpp │ │ │ └── tls.hpp │ ├── base │ │ ├── connection.hpp │ │ └── endpoint.hpp │ ├── debug │ │ ├── base.hpp │ │ ├── connection.hpp │ │ └── endpoint.hpp │ ├── iostream │ │ ├── base.hpp │ │ ├── connection.hpp │ │ └── endpoint.hpp │ └── stub │ │ ├── base.hpp │ │ ├── connection.hpp │ │ └── endpoint.hpp ├── uri.hpp ├── utf8_validator.hpp ├── utilities.hpp └── version.hpp └── ws_server.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.so 2 | *.pyc 3 | *.o 4 | *.d 5 | *.bin 6 | *__pycache__* 7 | tags 8 | *.ropeproject* 9 | *.rep 10 | *.swp 11 | *.swo 12 | *.DS_Store 13 | build 14 | CMakeFiles 15 | CMakeCache.txt 16 | latest? 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | ######################### 2 | # project configuration # 3 | ######################### 4 | 5 | cache: 6 | apt: true 7 | directories: 8 | - $HOME/deps 9 | 10 | # C++ project 11 | language: cpp 12 | python: 13 | - 3.6 14 | compiler: 15 | - gcc 16 | - clang 17 | addons: 18 | apt: 19 | sources: 20 | - ubuntu-toolchain-r-test 21 | packages: 22 | - gcc-4.9 23 | - g++-4.9 24 | - clang 25 | - libpython3-dev 26 | - libtbb-dev 27 | install: 28 | # create deps dir if not existing 29 | - DEPS_DIR=${HOME}/deps 30 | - mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR} 31 | - python3-config --cflags --ldflags 32 | - | 33 | CMAKE_URL="http://www.cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz" 34 | mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake 35 | export PATH=${DEPS_DIR}/cmake/bin:${PATH} 36 | - cd - 37 | 38 | script: 39 | - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi 40 | - (mkdir rts/build_MC && cd rts/build_MC && cmake .. -DGAME_DIR=../game_MC && make) 41 | - (mkdir rts/build_CF && cd rts/build_CF && cmake .. -DGAME_DIR=../game_CF && make) 42 | - (mkdir rts/build_TD && cd rts/build_TD && cmake .. -DGAME_DIR=../game_TD && make) 43 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct) so that you can understand what actions will and will not be tolerated. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD License 2 | 3 | For ELF software 4 | 5 | Copyright (c) 2017-present, Facebook, Inc. All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, 8 | are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name Facebook nor the names of its contributors may be used to 18 | endorse or promote products derived from this software without specific 19 | prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /atari/.gitignore: -------------------------------------------------------------------------------- 1 | *.bin 2 | -------------------------------------------------------------------------------- /atari/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 3.3) 2 | project(atari) 3 | set(CMAKE_CXX_STANDARD 11) 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") 5 | if(NOT CMAKE_BUILD_TYPE) 6 | set(CMAKE_BUILD_TYPE Release) 7 | endif() 8 | set(CMAKE_CXX_FLAGS_DEBUG "-g") 9 | set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native") 10 | 11 | 12 | # add elf and vendor 13 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../elf/ ${CMAKE_BINARY_DIR}/elf/) 14 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../vendor/ ${CMAKE_BINARY_DIR}/vendor/) 15 | 16 | # add ALE 17 | find_package(PkgConfig) 18 | pkg_check_modules(ALE REQUIRED ale) 19 | include_directories(SYSTEM ${ALE_INCLUDE_DIRS}) 20 | link_directories(${ALE_LIBRARY_DIRS}) 21 | 22 | 23 | # the python lib 24 | file(GLOB SOURCES *.cc) 25 | pybind11_add_module(atari_game ${SOURCES}) 26 | target_link_libraries(atari_game PRIVATE elf ale) 27 | set_target_properties(atari_game 28 | PROPERTIES 29 | LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") 30 | 31 | 32 | add_executable(benchmark-ale benchmark-ale.cpp) 33 | target_link_libraries(benchmark-ale ale concurrentqueue) 34 | 35 | add_executable(benchmark-atari benchmark-atari.cpp atari_game.cc) 36 | target_link_libraries(benchmark-atari ale elf pybind11) 37 | -------------------------------------------------------------------------------- /atari/benchmark-atari.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | //File: benchmark-atari.cpp 10 | //g++ -O3 benchmark-atari.cc atari_game.cc -std=c++11 `pkg-config --cflags --libs ale` -I../vendor `python-config --cflags --ldflags` -DUSE_PYBIND11 && ./a.out 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | using namespace std; 23 | #include "timer.hh" 24 | #include "atari_game.h" 25 | #include "game_context.h" 26 | 27 | int main() { 28 | ContextOptions co; 29 | co.num_games = 256; 30 | 31 | GameOptions go; 32 | go.rom_file = "pong.bin"; 33 | go.frame_skip = 4; 34 | go.seed = 42; 35 | 36 | GameContext GC{co, go}; 37 | 38 | int batchsize = 16; 39 | GroupStat stat; 40 | GC.AddCollectors(batchsize, 1, 0, stat); 41 | 42 | cout << "Start timing ..." << endl; 43 | int N = 30000; 44 | Timer tm; 45 | GC.Start(); 46 | for (int i = 0; i < N; ++i) { 47 | auto v = GC.Wait(0); 48 | GC.Steps(v); 49 | if (i == 0) { 50 | tm.restart(); 51 | } 52 | } 53 | GC.Stop(); 54 | cout << "tm duration" << tm.duration() << endl; 55 | cout << "seconds per iter:" << tm.duration() / N << endl; 56 | cout << N / tm.duration() * batchsize * go.frame_skip << endl; 57 | } 58 | -------------------------------------------------------------------------------- /atari/benchmark-atari.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | #!/usr/bin/env python 8 | # -*- coding: utf-8 -*- 9 | # File: benchmark-atari.py 10 | # Author: Yuxin Wu 11 | 12 | import random 13 | import time 14 | from time import sleep 15 | import numpy as np 16 | import sys 17 | 18 | from six.moves import range 19 | import atari_game as atari 20 | from game_utils import initialize_game 21 | from collections import Counter 22 | 23 | Niter = 30000 24 | frame_skip = 4 25 | 26 | def benchmark(ngame): 27 | batchsize = 16 28 | co, opt = initialize_game( 29 | batchsize, num_games=ngame, 30 | frame_skip=frame_skip, T=4) 31 | GC = atari.GameContext(co, opt) 32 | start = time.time() 33 | sys.stderr.write("Start benchmark ngame={}...\n".format(ngame)) 34 | 35 | stats = Counter() 36 | for i in range(ngame): stats[i] = 0 37 | 38 | for k in range(Niter): 39 | infos = GC.Wait(0) 40 | #for i in range(len(infos)): 41 | # stats[infos[i].meta().id] += 1 42 | GC.Steps(infos) 43 | print(stats) 44 | return Niter / (time.time() - start) * frame_skip * batchsize 45 | 46 | if __name__ == '__main__': 47 | for ngame in [64, 128, 256, 512, 1024]: 48 | fps = benchmark(ngame) 49 | print("NGame={}, FPS={}".format(ngame, fps)) 50 | -------------------------------------------------------------------------------- /atari/python_wrapper.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | //File: python_wrapper.cc 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "elf/pybind_helper.h" 16 | 17 | #include "game_context.h" 18 | 19 | namespace py = pybind11; 20 | 21 | PYBIND11_MODULE(atari_game, m) { 22 | register_common_func(m); 23 | 24 | CONTEXT_REGISTER(GameContext) 25 | .def("GetParams", &GameContext::GetParams); 26 | PYCLASS_WITH_FIELDS(m, GameOptions) 27 | .def(py::init<>()); 28 | } 29 | -------------------------------------------------------------------------------- /atari/timer.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class Timer { 10 | public: 11 | using Clock = std::chrono::high_resolution_clock; 12 | Timer() { 13 | restart(); 14 | } 15 | 16 | // return current unix timestamp 17 | void restart() { 18 | m_start_time = std::chrono::high_resolution_clock::now(); 19 | } 20 | 21 | // return duration in seconds 22 | double duration() const { 23 | auto now = std::chrono::high_resolution_clock::now(); 24 | auto m = std::chrono::duration_cast(now - m_start_time).count(); 25 | return m * 1.0 / 1e6; 26 | } 27 | 28 | protected: 29 | std::chrono::time_point m_start_time; 30 | 31 | }; 32 | 33 | 34 | class GuardedTimer: public Timer { 35 | public: 36 | GuardedTimer(const std::string& msg, bool enabled=true): 37 | GuardedTimer([msg](double duration){ 38 | std::cout << msg << ": " << std::to_string(duration * 1000.) << " milliseconds." << std::endl; 39 | }) 40 | { enabled_ = enabled; } 41 | 42 | GuardedTimer(const char* msg, bool enabled=true): 43 | GuardedTimer(std::string(msg), enabled) {} 44 | 45 | GuardedTimer(std::function callback): 46 | m_callback(callback) 47 | { } 48 | 49 | ~GuardedTimer() { 50 | if (enabled_) 51 | m_callback(duration()); 52 | } 53 | 54 | protected: 55 | bool enabled_; 56 | std::function m_callback; 57 | 58 | }; 59 | 60 | -------------------------------------------------------------------------------- /console_df.sh: -------------------------------------------------------------------------------- 1 | game=./go/game model=df_policy model_file=./go/df_model python3 df_console.py --mode online "$@" 2 | -------------------------------------------------------------------------------- /console_df_check_train.sh: -------------------------------------------------------------------------------- 1 | game=./go/game model=df_policy model_file=./go/df_model python3 df_console.py --list_file ~/local/go/go_gogod/train.lst --data_aug 0 "$@" 2 | -------------------------------------------------------------------------------- /console_df_mcts.sh: -------------------------------------------------------------------------------- 1 | game=./go/game model=df_policy model_file=./go/df_model python3 df_console.py --online --use_mcts "$@" 2 | -------------------------------------------------------------------------------- /df_selfplay.sh: -------------------------------------------------------------------------------- 1 | game=./go/game model=df model_file=./go/df_model2 python3 df_selfplay.py --mode selfplay "$@" 2 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | html 2 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | SPHINX ?= sphinx-build 2 | SRC = ./source 3 | TARGET = ./html 4 | 5 | all: 6 | $(SPHINX) -b html $(SRC) $(TARGET) 7 | 8 | clean: 9 | rm -rvf $(TARGET) 10 | -------------------------------------------------------------------------------- /docs/source/RTS-engine.rst: -------------------------------------------------------------------------------- 1 | RTS engine 2 | ========== 3 | A simple Real-time Strategy (RTS) engine. 4 | -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | sys.path.insert(0, os.path.abspath('../../')) 3 | 4 | import sphinx_rtd_theme 5 | 6 | extensions = [ 7 | 'sphinx.ext.autodoc', 8 | 'sphinx.ext.autosummary', 9 | 'sphinx.ext.doctest', 10 | 'sphinx.ext.intersphinx', 11 | 'sphinx.ext.todo', 12 | 'sphinx.ext.coverage', 13 | 'sphinx.ext.mathjax', 14 | 'sphinx.ext.napoleon', 15 | 'sphinx.ext.viewcode', 16 | ] 17 | 18 | source_suffix = '.rst' 19 | 20 | master_doc = 'index' 21 | 22 | # General information about the project. 23 | project = 'ELF' 24 | copyright = '2017, ELF Contributors' 25 | author = 'ELF Contributors' 26 | 27 | release = 'master' 28 | 29 | # The language for content autogenerated by Sphinx. Refer to documentation 30 | # for a list of supported languages. 31 | # 32 | # This is also used if you do content translation via gettext catalogs. 33 | # Usually you set "language" from the command line for these cases. 34 | language = None 35 | 36 | # List of patterns, relative to source directory, that match files and 37 | # directories to ignore when looking for source files. 38 | # This patterns also effect to html_static_path and html_extra_path 39 | exclude_patterns = [] 40 | 41 | # The name of the Pygments (syntax highlighting) style to use. 42 | pygments_style = 'sphinx' 43 | 44 | # If true, `todo` and `todoList` produce output, else they produce nothing. 45 | todo_include_todos = True 46 | 47 | html_theme = 'sphinx_rtd_theme' 48 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] 49 | -------------------------------------------------------------------------------- /docs/source/imgs/hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/docs/source/imgs/hierarchy.png -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | ELF 2 | ========== 3 | 4 | ELF is an end-to-end, extensive, lightweight and flexible platform for game research. 5 | 6 | Code Hierarchy 7 | -------------- 8 | ELF is organized as follows. 9 | 10 | .. image:: /imgs/hierarchy.png 11 | 12 | * The folder ``elf`` contains the game-independent codebase to handle concurrent simulation. 13 | * The folder ``atari`` contains the wrapper and model for Atari games. ALE is required (`ALE `_). 14 | * The folder ``rts/engine`` contains the RTS engine. ``rts/game_MC``, ``rts/game_CF`` and ``rts/game_TD`` are the three games built on top of the engine. 15 | 16 | Components 17 | ---------- 18 | Python APIs: 19 | 20 | * :doc:`rlpytorch`. The Reinforcement Learning backend built from PyTorch. 21 | * :doc:`wrapper-python`. The Python interface of wrapper. 22 | 23 | C++ APIs: 24 | 25 | * :doc:`wrapper`. The wrapper toolbox that make a single-threaded game environment into a library that supports multithreading. 26 | 27 | RTS: 28 | 29 | * :doc:`RTS-engine`. The miniature RTS engine. 30 | -------------------------------------------------------------------------------- /docs/source/methods.rst: -------------------------------------------------------------------------------- 1 | RLPyTorch.methods 2 | ================= 3 | 4 | .. currentmodule:: rlpytorch.methods 5 | 6 | .. autoclass:: ActorCritic 7 | :members: 8 | 9 | .. automethod:: __init__ 10 | .. autoclass:: DiscountedReward 11 | :members: 12 | 13 | .. automethod:: __init__ 14 | .. autoclass:: PolicyGradient 15 | :members: 16 | 17 | .. automethod:: __init__ 18 | .. autoclass:: ValueMatcher 19 | :members: 20 | 21 | .. automethod:: __init__ 22 | 23 | .. automodule:: rlpytorch.methods.utils 24 | :members: 25 | 26 | * :doc:`rlpytorch`. Go back. 27 | -------------------------------------------------------------------------------- /docs/source/runner.rst: -------------------------------------------------------------------------------- 1 | RLPyTorch.runner 2 | ================= 3 | 4 | .. currentmodule:: rlpytorch.runner 5 | 6 | .. autoclass:: EvalIters 7 | :members: 8 | 9 | .. automethod:: __init__ 10 | .. autoclass:: MultiProcessRun 11 | :members: 12 | 13 | .. automethod:: __init__ 14 | 15 | .. autoclass:: SingleProcessRun 16 | :members: 17 | 18 | .. automethod:: __init__ 19 | 20 | .. automodule:: rlpytorch.runner.parameter_server 21 | 22 | .. autoclass:: Cond 23 | :members: 24 | 25 | .. autoclass:: ParameterServer 26 | :members: 27 | 28 | .. automethod:: __init__ 29 | 30 | .. autoclass:: SharedData 31 | :members: 32 | 33 | .. automethod:: __init__ 34 | 35 | * :doc:`rlpytorch`. Go back. 36 | -------------------------------------------------------------------------------- /docs/source/sampler.rst: -------------------------------------------------------------------------------- 1 | RLPyTorch.sampler 2 | ================= 3 | 4 | .. currentmodule:: rlpytorch.sampler 5 | 6 | .. autoclass:: Sampler 7 | :members: 8 | 9 | .. automethod:: __init__ 10 | 11 | .. automodule:: rlpytorch.sampler.sample_methods 12 | :members: 13 | 14 | * :doc:`rlpytorch`. Go back. 15 | -------------------------------------------------------------------------------- /docs/source/stats.rst: -------------------------------------------------------------------------------- 1 | RLPyTorch.stats 2 | ================= 3 | 4 | .. automodule:: rlpytorch.stats 5 | :members: 6 | 7 | .. autoclass:: EvalCount 8 | :members: 9 | 10 | .. automethod:: __init__ 11 | 12 | .. autoclass:: RewardCount 13 | :members: 14 | 15 | .. automethod:: __init__ 16 | 17 | .. autoclass:: WinRate 18 | :members: 19 | 20 | .. automethod:: __init__ 21 | 22 | .. autoclass:: Stats 23 | :members: 24 | 25 | .. automethod:: __init__ 26 | 27 | * :doc:`rlpytorch`. Go back. 28 | -------------------------------------------------------------------------------- /docs/source/trainer.rst: -------------------------------------------------------------------------------- 1 | RLPyTorch.trainer 2 | ================= 3 | 4 | .. currentmodule:: rlpytorch.trainer.timer 5 | 6 | .. autoclass:: RLTimer 7 | :members: 8 | 9 | .. automodule:: rlpytorch.trainer.trainer 10 | :members: 11 | 12 | .. autoclass:: Evaluator 13 | :members: 14 | 15 | .. autoclass:: Trainer 16 | :members: 17 | 18 | * :doc:`rlpytorch`. Go back. 19 | -------------------------------------------------------------------------------- /docs/source/wrapper.rst: -------------------------------------------------------------------------------- 1 | Wrapper 2 | ======= 3 | -------------------------------------------------------------------------------- /elf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # find sources 2 | file(GLOB SOURCES lib/*.cc tar_loader.cc) 3 | 4 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") 5 | # require at least gcc 4.9 6 | if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) 7 | message(FATAL_ERROR "GCC version must be at least 4.9!") 8 | endif() 9 | endif() 10 | 11 | add_library(elf INTERFACE) 12 | target_sources(elf INTERFACE ${SOURCES}) 13 | target_link_libraries(elf INTERFACE concurrentqueue tbb microtar) 14 | target_include_directories(elf 15 | INTERFACE $ 16 | ) 17 | 18 | target_compile_definitions(elf INTERFACE USE_TBB) 19 | # git commit 20 | execute_process(COMMAND git rev-parse HEAD 21 | OUTPUT_VARIABLE GIT_COMMIT_HASH) 22 | execute_process(COMMAND git diff-index --quiet HEAD -- 23 | RESULT_VARIABLE GIT_STAGED) 24 | string(STRIP ${GIT_COMMIT_HASH} GIT_COMMIT_HASH) 25 | target_compile_definitions(elf INTERFACE 26 | GIT_COMMIT_HASH=${GIT_COMMIT_HASH}) 27 | if(NOT ${GIT_STAGED}) 28 | target_compile_definitions(elf INTERFACE 29 | GIT_UNSTAGED=staged) 30 | endif() 31 | 32 | -------------------------------------------------------------------------------- /elf/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from .utils_elf import GCWrapper 8 | from .utils_elf import Batch 9 | from .context_utils import ContextArgs 10 | from .more_labels import MoreLabels 11 | -------------------------------------------------------------------------------- /elf/common.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | struct SeqInfo { 12 | int seq; 13 | int game_counter; 14 | char last_terminal; 15 | 16 | SeqInfo() : seq(0), game_counter(0), last_terminal(0) { } 17 | void Inc() { seq ++; last_terminal = 0; } 18 | void NewEpisode() { seq = 0; game_counter ++; last_terminal = 1; } 19 | }; 20 | 21 | 22 | -------------------------------------------------------------------------------- /elf/compile_test_mcts.sh: -------------------------------------------------------------------------------- 1 | g++ -std=c++11 -lstdc++ test_tree_search.cc -I../vendor 2 | -------------------------------------------------------------------------------- /elf/lib/debugutils.hh: -------------------------------------------------------------------------------- 1 | // File: debugutils.hh 2 | // Date: Fri Jun 09 11:53:56 2017 -0700 3 | 4 | #pragma once 5 | #include 6 | #include 7 | 8 | #ifdef _WIN32 9 | #define __attribute__(x) 10 | #endif 11 | 12 | #define P(a) std::cout << (a) << std::endl 13 | #define PP(a) std::cout << #a << ": " << (a) << std::endl 14 | #define PA(arr) \ 15 | do { \ 16 | std::cout << #arr << ": "; \ 17 | std::copy(begin(arr), end(arr), std::ostream_iterator::type::value_type>(std::cout, " ")); \ 18 | std::cout << std::endl; \ 19 | } while (0) 20 | #define PV3(vec) \ 21 | std::cout << #vec << "=(" << vec.x << "," << vec.y << "," << vec.z << ")" << std::endl 22 | 23 | namespace elf { 24 | 25 | void __m_assert_check__(bool val, const char *expr, 26 | const char *file, const char *func, int line); 27 | 28 | 29 | void error_exit(const char *msg) __attribute__((noreturn)); 30 | 31 | inline void error_exit(const std::string& s) __attribute__((noreturn)); 32 | void error_exit(const std::string& s) { 33 | error_exit(s.c_str()); 34 | } 35 | 36 | // keep print_debug 37 | #define print_debug(fmt, ...) \ 38 | elf::__print_debug__(__FILE__, __func__, __LINE__, fmt, ## __VA_ARGS__) 39 | 40 | void __print_debug__(const char *file, const char *func, int line, const char *fmt, ...) 41 | __attribute__((format(printf, 4, 5))); 42 | 43 | #ifdef DEBUG 44 | 45 | #define m_assert(expr) \ 46 | elf::__m_assert_check__((expr), # expr, __FILE__, __func__ , __LINE__) 47 | 48 | #else 49 | 50 | //#define print_debug(fmt, ...) 51 | 52 | #define m_assert(expr) 53 | 54 | #endif 55 | } 56 | -------------------------------------------------------------------------------- /elf/lib/strutils.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #ifdef _WIN32 7 | #define __attribute__(x) 8 | #endif 9 | 10 | 11 | namespace elf { 12 | 13 | std::string TERM_COLOR(int k); 14 | 15 | #define COLOR_RED "\x1b[31m" 16 | #define COLOR_GREEN "\x1b[32m" 17 | #define COLOR_YELLOW "\x1b[33m" 18 | #define COLOR_BLUE "\x1b[34m" 19 | #define COLOR_MAGENTA "\x1b[35m" 20 | #define COLOR_CYAN "\x1b[36m" 21 | #define COLOR_RESET "\x1b[0m" 22 | 23 | void c_printf(const char* col, const char* fmt, ...); 24 | 25 | void c_fprintf(const char* col, FILE* fp, const char* fmt, ...); 26 | 27 | __attribute__ (( format( printf, 1, 2 ) )) 28 | std::string ssprintf(const char *fmt, ...); 29 | 30 | inline bool endswith(const char* str, const char* suffix) { 31 | if (!str || !suffix) return false; 32 | auto l1 = strlen(str), l2 = strlen(suffix); 33 | if (l2 > l1) return false; 34 | return strncmp(str + l1 - l2, suffix, l2) == 0; 35 | } 36 | 37 | std::vector strsplit( 38 | const std::string &str, const std::string &sep); 39 | 40 | 41 | // 'a/b/../c/d/e/../f/./g' -> a/c/d/f/g 42 | std::string squeeze_path(const std::string&); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /elf/member_check.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | 14 | #define MEMBER_CHECK(member) \ 15 | \ 16 | template \ 17 | struct has_##member : std::false_type { };\ 18 | \ 19 | template \ 20 | struct has_##member <__T, decltype((void) __T::member, 0)> : std::true_type { }; 21 | 22 | 23 | #define MEMBER_FUNC_CHECK(func) \ 24 | template \ 25 | struct has_func_##func \ 26 | { \ 27 | template static char test( decltype(&__C::func) ) ; \ 28 | template static long test(...); \ 29 | enum { value = sizeof(test<__T>(0)) == sizeof(char) }; \ 30 | }; 31 | -------------------------------------------------------------------------------- /elf/more_labels.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from rlpytorch import ArgsProvider 8 | 9 | class MoreLabels: 10 | def __init__(self): 11 | self.args = ArgsProvider( 12 | call_from = self, 13 | define_args = [ 14 | ("additional_labels", dict(type=str, default=None, help="Add additional labels in the batch. E.g., id,seq,last_terminal")), 15 | ] 16 | ) 17 | 18 | def add_labels(self, desc): 19 | args = self.args 20 | if args.additional_labels is None: return 21 | 22 | extra = args.additional_labels.split(",") 23 | for _, v in desc.items(): 24 | v["input"]["keys"].update(extra) 25 | 26 | -------------------------------------------------------------------------------- /elf/replay_loader.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #include "replay_loader.h" 10 | 11 | -------------------------------------------------------------------------------- /elf/replay_loader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "shared_replay_buffer.h" 12 | 13 | namespace elf { 14 | 15 | using namespace std; 16 | 17 | template 18 | class ReplayLoaderT { 19 | public: 20 | using RIterator = typename Record::iterator; 21 | using RBuffer = SharedReplayBuffer; 22 | using GenFunc = typename RBuffer::GenFunc; 23 | 24 | static void Init(GenFunc func) { 25 | _rbuffer.reset(new RBuffer(func)); 26 | } 27 | 28 | void Reload() { 29 | while (true) { 30 | K k = get_key(); 31 | const auto &record = _rbuffer->Get(k); 32 | _it = record.begin(); 33 | if (after_reload(k, _it)) return; 34 | } 35 | } 36 | 37 | const RIterator &curr() const { return _it; } 38 | void increment() { ++ _it; } 39 | 40 | private: 41 | // Shared buffer for OfflineLoader. 42 | static std::unique_ptr _rbuffer; 43 | 44 | RIterator _it; 45 | 46 | protected: 47 | // The function return true if the load is valid, otherwise return false. 48 | virtual bool after_reload(const K& k, RIterator &it) = 0; 49 | virtual K get_key() = 0; 50 | }; 51 | 52 | template 53 | std::unique_ptr> ReplayLoaderT::_rbuffer; 54 | 55 | } // namespace elf 56 | -------------------------------------------------------------------------------- /elf/shared_replay_buffer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | template 16 | class SharedReplayBuffer { 17 | public: 18 | using GenFunc = std::function (const Key &)>; 19 | 20 | SharedReplayBuffer(GenFunc gen) : _gen(gen) { } 21 | void InitRecords(const std::vector &keys) { 22 | std::lock_guard lock(_mutex); 23 | for (const auto &key : keys) add_record_no_lock(key); 24 | } 25 | 26 | bool HasKey(const Key &key) const { return _buffer.find(key) != _buffer.end(); } 27 | 28 | const Record &Get(const Key& key) { 29 | typename BufferType::const_iterator it = _buffer.find(key); 30 | if (it == _buffer.end()) { 31 | std::lock_guard lock(_mutex); 32 | // Check again. 33 | it = _buffer.find(key); 34 | if (it == _buffer.end()) it = add_record_no_lock(key); 35 | } 36 | return *it->second; 37 | } 38 | 39 | private: 40 | using BufferType = std::map>; 41 | 42 | BufferType _buffer; 43 | std::mutex _mutex; 44 | GenFunc _gen; 45 | 46 | typename BufferType::const_iterator add_record_no_lock(const Key &key) { 47 | assert(_gen != nullptr); 48 | return _buffer.emplace(make_pair(key, _gen(key))).first; 49 | } 50 | }; 51 | 52 | -------------------------------------------------------------------------------- /elf/signal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | #include 11 | 12 | namespace elf { 13 | 14 | class Signal { 15 | public: 16 | Signal(const std::atomic_bool &d, const std::atomic_bool &prepare_stop) 17 | : done_(d), prepare_stop_(prepare_stop) { 18 | } 19 | 20 | bool IsDone() const { return done_.load(); } 21 | const std::atomic_bool &done() const { return done_; } 22 | bool PrepareStop() const { return prepare_stop_.load(); } 23 | 24 | private: 25 | const std::atomic_bool &done_; 26 | const std::atomic_bool &prepare_stop_; 27 | }; 28 | 29 | } // namespace elf 30 | -------------------------------------------------------------------------------- /elf/tar_loader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | #include "microtar.h" 14 | 15 | namespace elf { 16 | 17 | namespace tar { 18 | 19 | extern bool file_is_tar(const std::string& filename); 20 | 21 | class TarLoader { 22 | private: 23 | mtar_t tar; 24 | public: 25 | TarLoader(const std::string &tar_filename); 26 | std::vector List(); 27 | std::string Load(const std::string &filename); 28 | ~TarLoader(); 29 | }; 30 | 31 | class TarWriter { 32 | private: 33 | mtar_t tar; 34 | public: 35 | TarWriter(const std::string &tar_filename); 36 | void Write(const std::string &filename, const std::string &contents); 37 | ~TarWriter(); 38 | }; 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /elf_python/README.md: -------------------------------------------------------------------------------- 1 | Python Implementation of Concurrent Game Environemnt in ELF 2 | ============================================================ 3 | Many games do not have C interface, which restricts the usage of ELF. Therefore we also provide a simple Python implementation to run concurrent game environments, using Python multiprocessing library. 4 | 5 | For sample code, please check `./ex_elfpy.py`. You can put any environment into it, e.g, OpenAI gym, that wraps one game instance with one Python interface. 6 | 7 | 8 | -------------------------------------------------------------------------------- /elf_python/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from .simulator import Simulator 8 | from .GCWrapper import GCWrapper 9 | -------------------------------------------------------------------------------- /elf_python/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from queue import Queue, Full, Empty 8 | 9 | import msgpack 10 | import msgpack_numpy 11 | msgpack_numpy.patch() 12 | 13 | def dumps(obj): 14 | return msgpack.dumps(obj, use_bin_type=True) 15 | 16 | def loads(buf): 17 | return msgpack.loads(buf) 18 | 19 | def check_done_flag(done_flag): 20 | if done_flag is not None: 21 | with done_flag.get_lock(): 22 | return done_flag.value 23 | return False 24 | 25 | def queue_get(q, done_flag=None, fail_comment=None): 26 | if done_flag is None: 27 | return q.get() 28 | done = False 29 | while not done: 30 | try: 31 | return q.get(True, 0.01) 32 | except Empty: 33 | if fail_comment is not None: 34 | print(fail_comment) 35 | if check_done_flag(done_flag): 36 | done = True 37 | # Return 38 | return None 39 | 40 | def queue_put(q, item, done_flag=None, fail_comment=None): 41 | if done_flag is None: 42 | q.put(item) 43 | return True 44 | done = False 45 | while not done: 46 | try: 47 | q.put(item, True, 0.01) 48 | return True 49 | except Full: 50 | if fail_comment is not None: 51 | print(fail_comment) 52 | if check_done_flag(done_flag): 53 | done = True 54 | return False 55 | -------------------------------------------------------------------------------- /eval.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | #!/usr/bin/env python 8 | # -*- coding: utf-8 -*- 9 | 10 | from datetime import datetime 11 | 12 | import sys 13 | import os 14 | 15 | from rlpytorch import load_env, Evaluator, ArgsProvider, EvalIters 16 | 17 | if __name__ == '__main__': 18 | evaluator = Evaluator(stats=False) 19 | eval_iters = EvalIters() 20 | env, args = load_env(os.environ, overrides=dict(actor_only=True), evaluator=evaluator, eval_iters=eval_iters) 21 | 22 | GC = env["game"].initialize() 23 | 24 | model = env["model_loaders"][0].load_model(GC.params) 25 | env["mi"].add_model("actor", model, cuda=not args.gpu is None, gpu_id=args.gpu) 26 | env["mi"]["actor"].eval() 27 | 28 | def actor(batch): 29 | reply = evaluator.actor(batch) 30 | ''' 31 | s = batch["s"][0][0] 32 | seq = batch["seq"][0][0] 33 | for i in range(s.size(0)): 34 | print("[seq=%d][c=%d]: %s" % (seq, i, str(s[i]))) 35 | print("[seq=%d]: %s" % (seq, str(reply["pi"][0]))) 36 | print("[seq=%d]: %s" % (seq, str(reply["a"][0]))) 37 | ''' 38 | eval_iters.stats.feed_batch(batch) 39 | return reply 40 | 41 | evaluator.setup(sampler=env["sampler"], mi=env["mi"]) 42 | 43 | GC.reg_callback("actor", actor) 44 | GC.Start() 45 | 46 | evaluator.episode_start(0) 47 | 48 | for n in eval_iters.iters(): 49 | GC.Run() 50 | GC.Stop() 51 | 52 | -------------------------------------------------------------------------------- /eval_atari.sh: -------------------------------------------------------------------------------- 1 | ROM=$1 2 | MODEL=$2 3 | GPU=$3 4 | 5 | game=./atari/game model=actor_critic model_file=./atari/model python3 eval.py --num_games 128 --batchsize 32 --tqdm --gpu $GPU --rom_file $ROM --load $MODEL --eval_stats rewards --reward_clip -1 --num_eval 500 --additional_labels id,last_terminal --keys_in_reply V,rv 6 | -------------------------------------------------------------------------------- /eval_lstm.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | #!/usr/bin/env python 8 | # -*- coding: utf-8 -*- 9 | 10 | import argparse 11 | from datetime import datetime 12 | 13 | import sys 14 | import os 15 | 16 | from rlpytorch import LSTMTrainer, Sampler, EvalIters, load_env, ModelLoader, ArgsProvider, ModelInterface 17 | 18 | if __name__ == '__main__': 19 | trainer = LSTMTrainer() 20 | eval_iters = EvalIters() 21 | env, all_args = load_env(os.environ, overrides=dict(actor_only=True), trainer=trainer, eval_iters=eval_iters) 22 | 23 | GC = env["game"].initialize() 24 | 25 | model = env["model_loaders"][0].load_model(GC.params) 26 | mi = ModelInterface() 27 | mi.add_model("model", model) 28 | mi.add_model("actor", model, copy=True, cuda=all_args.gpu is not None, gpu_id=all_args.gpu) 29 | 30 | trainer.setup(sampler=env["sampler"], mi=env["mi"]) 31 | 32 | def actor(batch): 33 | reply = trainer.actor(batch) 34 | eval_iters.stats.feed_batch(batch) 35 | return reply 36 | 37 | GC.reg_callback("actor", actor) 38 | GC.Start() 39 | 40 | trainer.episode_start(0) 41 | 42 | for n in eval_iters.iters(): 43 | GC.Run() 44 | 45 | GC.Stop() 46 | -------------------------------------------------------------------------------- /eval_minirts.sh: -------------------------------------------------------------------------------- 1 | MODEL=$1 2 | FRAMESKIP=$2 3 | NUM_EVAL=10000 4 | 5 | game=./rts/game_MC/game model_file=./rts/game_MC/model model=actor_critic python3 eval.py --num_games 1024 --batchsize 128 --tqdm --load ${MODEL} --gpu 0 --players "fs=50,type=AI_NN;fs=${FRAMESKIP},type=AI_SIMPLE" --eval_stats winrate --num_eval $NUM_EVAL --additional_labels id,last_terminal,seq --shuffle_player --num_frames_in_state 1 --greedy --keys_in_reply V #--omit_keys Wt,Wt2,Wt3 # 6 | -------------------------------------------------------------------------------- /eval_minirts2.sh: -------------------------------------------------------------------------------- 1 | MODEL=$1 2 | FRAMESKIP=$2 3 | 4 | game=./rts/game_MC/game model_file=./rts/game_MC/model model=actor_critic taskset -c 30-40 python3 eval.py --num_games 128 --batchsize 32 --tqdm --load ${MODEL} --gpu 4 --fs_opponent ${FRAMESKIP} --latest_start 0 --opponent_type AI_SIMPLE --eval_stats winrate --num_eval 10000 --additional_labels id,last_terminal --arch "ccpccp;-,-,-,-,-" --greedy 5 | -------------------------------------------------------------------------------- /eval_selfplay_aivsai.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | #!/usr/bin/env python 8 | # -*- coding: utf-8 -*- 9 | 10 | import argparse 11 | from datetime import datetime 12 | 13 | import sys 14 | import os 15 | 16 | from rlpytorch import * 17 | 18 | if __name__ == '__main__': 19 | verbose = False 20 | runner = SingleProcessRun() 21 | evaluators = [ Evaluator(name="eval" + str(i), verbose=verbose) for i in range(2) ] 22 | env, all_args = load_env(os.environ, num_models=2, evaluators=evaluators, runner=runner, overrides=dict(actor_only=True)) 23 | 24 | GC = env["game"].initialize_selfplay() 25 | 26 | for i, (model_loader, e) in enumerate(zip(env["model_loaders"], evaluators)): 27 | model = model_loader.load_model(GC.params) 28 | mi = ModelInterface() 29 | mi.add_model("actor", model, copy=False) 30 | e.setup(sampler=env["sampler"], mi=mi) 31 | GC.reg_callback("actor%d" % i, e.actor) 32 | 33 | def summary(i): 34 | for e in evaluators: 35 | e.episode_summary(i) 36 | 37 | def start(i): 38 | for e in evaluators: 39 | e.episode_start(i) 40 | 41 | runner.setup(GC, episode_summary=summary, episode_start=start) 42 | runner.run() 43 | 44 | -------------------------------------------------------------------------------- /go/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 3.3) 2 | project(go) 3 | set(CMAKE_CXX_STANDARD 11) 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") 5 | if(NOT CMAKE_BUILD_TYPE) 6 | set(CMAKE_BUILD_TYPE Release) 7 | endif() 8 | set(CMAKE_CXX_FLAGS_DEBUG "-g") 9 | set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native") 10 | 11 | 12 | # add elf and vendor 13 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../elf/ ${CMAKE_BINARY_DIR}/elf/) 14 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../vendor/ ${CMAKE_BINARY_DIR}/vendor/) 15 | 16 | # the python lib 17 | file(GLOB SOURCES *.cc) 18 | pybind11_add_module(go_game ${SOURCES}) 19 | target_link_libraries(go_game PRIVATE elf) 20 | set_target_properties(go_game 21 | PROPERTIES 22 | LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") 23 | -------------------------------------------------------------------------------- /go/ai.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "go_game_specific.h" 12 | #include "go_state.h" 13 | #include "elf/ai.h" 14 | 15 | using AI = elf::AI_T; 16 | using AIWithComm = elf::AIWithCommT; 17 | using AIHoldStateWithComm = elf::AIHoldStateWithCommT; 18 | -------------------------------------------------------------------------------- /go/common.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #include "common.h" 10 | #include 11 | #include 12 | 13 | double __attribute__ ((noinline)) wallclock(void) { 14 | struct timeval t; 15 | gettimeofday(&t, NULL); 16 | return (1.0e-6*t.tv_usec + t.tv_sec); 17 | } 18 | 19 | uint64_t __attribute__ ((noinline)) wallclock64() { 20 | return (uint64_t)(wallclock() * 1e6); 21 | } 22 | 23 | void dbg_printf(const char *format, ...) { 24 | (void)(format); 25 | #ifdef DEBUG 26 | va_list argptr; 27 | va_start(argptr, format); 28 | printf("INFO: "); 29 | vprintf(format, argptr); 30 | va_end(argptr); 31 | printf("\n"); 32 | fflush(stdout); 33 | #endif 34 | } 35 | 36 | void error(const char *format, ...) { 37 | va_list argptr; 38 | va_start(argptr, format); 39 | printf("ERROR: "); 40 | vprintf(format, argptr); 41 | va_end(argptr); 42 | printf("\n"); 43 | fflush(stdout); 44 | // Make an easy sev. 45 | char *a = NULL; 46 | *a = 1; 47 | exit(1); 48 | } 49 | 50 | 51 | -------------------------------------------------------------------------------- /go/common.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #ifndef _COMMON_H_ 10 | #define _COMMON_H_ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | double __attribute__ ((noinline)) wallclock(void); 22 | uint64_t __attribute__ ((noinline)) wallclock64(); 23 | 24 | void dbg_printf(const char *format, ...); 25 | void error(const char *format, ...); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | typedef unsigned short Coord; 32 | typedef unsigned char Stone; 33 | 34 | #define S_EMPTY 0 35 | #define S_BLACK 1 36 | #define S_WHITE 2 37 | #define S_OFF_BOARD 3 38 | 39 | // Two special moves. 40 | #define M_PASS 0 // (-1, -1) 41 | #define M_RESIGN 1 // (0, -1) 42 | #define M_INVALID 3 43 | 44 | #define STR_BOOL(s) ((s) ? "true" : "false") 45 | #define STR_STONE(s) ((s) == S_BLACK ? "B" : ((s) == S_WHITE ? "W" : "U")) 46 | 47 | #define timeit { \ 48 | double __start = wallclock(); \ 49 | 50 | #define endtime \ 51 | double __duration = wallclock() - __start; \ 52 | printf("Time spent = %lf\n", __duration); \ 53 | } 54 | 55 | #define endtime2(t) \ 56 | t = wallclock() - __start; \ 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /go/game.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | 10 | #pragma once 11 | 12 | #include "elf/pybind_helper.h" 13 | #include "elf/comm_template.h" 14 | #include "elf/ai_comm.h" 15 | 16 | #include "ai.h" 17 | #include "go_game_specific.h" 18 | #include "go_state.h" 19 | #include "offpolicy_loader.h" 20 | #include 21 | #include 22 | 23 | // Game interface for Go. 24 | class GoGame { 25 | private: 26 | int _game_idx = -1; 27 | uint64_t _seed = 0; 28 | GameOptions _options; 29 | ContextOptions _context_options; 30 | 31 | std::vector> _loaders; 32 | int _curr_loader_idx; 33 | std::mt19937 _rng; 34 | 35 | std::unique_ptr _ai; 36 | std::unique_ptr _human_player; 37 | 38 | // Only used when we want to run online 39 | GoState _state; 40 | 41 | std::vector _moves; 42 | std::unique_ptr _tar_writer; 43 | 44 | public: 45 | GoGame(int game_idx, const ContextOptions &context_options, const GameOptions& options); 46 | 47 | void Init(AIComm *ai_comm); 48 | 49 | void MainLoop(const elf::Signal& signal) { 50 | // Main loop of the game. 51 | while (! signal.IsDone()) { 52 | Act(signal); 53 | } 54 | } 55 | 56 | void Act(const elf::Signal &signal); 57 | string ShowBoard() const { return _state.ShowBoard(); } 58 | }; 59 | -------------------------------------------------------------------------------- /go/mcts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "elf/mcts.h" 12 | #include "go_ai.h" 13 | 14 | class MCTSActor { 15 | public: 16 | using Action = Coord; 17 | using State = GoState; 18 | using NodeResponse = mcts::NodeResponseT; 19 | 20 | MCTSActor(AIComm *ai_comm) { 21 | ai_.reset(new DirectPredictAI); 22 | ai_->InitAIComm(ai_comm); 23 | ai_->SetActorName("actor"); 24 | } 25 | 26 | void set_ostream(ostream *oo) { oo_ = oo; } 27 | 28 | NodeResponse &evaluate(const GoState &s) { 29 | ai_->Act(s, nullptr, nullptr); 30 | ai_->get_last_pi(&resp_.pi, oo_); 31 | resp_.value = ai_->get_last_value(); 32 | return resp_; 33 | } 34 | 35 | bool forward(GoState &s, Coord a) { 36 | return s.forward(a); 37 | } 38 | 39 | void SetId(int id) { 40 | ai_->SetId(id); 41 | } 42 | 43 | string info() const { return string(); } 44 | 45 | protected: 46 | NodeResponse resp_; 47 | unique_ptr ai_; 48 | ostream *oo_ = nullptr; 49 | }; 50 | 51 | using MCTSGoAI = elf::MCTSAIWithCommT; 52 | 53 | -------------------------------------------------------------------------------- /go/multiple_prediction.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | from torch.autograd import Variable 4 | import math 5 | 6 | from rlpytorch import ArgsProvider, add_err 7 | from rlpytorch.trainer import topk_accuracy 8 | 9 | class MultiplePrediction: 10 | def __init__(self): 11 | self.args = ArgsProvider( 12 | call_from = self, 13 | define_args = [ 14 | ("multipred_no_backprop", dict(action="store_true")), 15 | ], 16 | ) 17 | 18 | self.policy_loss = nn.NLLLoss().cuda() 19 | self.value_loss = nn.MSELoss().cuda() 20 | 21 | def update(self, mi, batch, stats): 22 | ''' Update given batch ''' 23 | # Current timestep. 24 | state_curr = mi["model"](batch.hist(0)) 25 | total_loss = None 26 | eps = 1e-6 27 | targets = batch.hist(0)["offline_a"] 28 | for i, pred in enumerate(state_curr["pis"]): 29 | if i == 0: 30 | prec1, prec5 = topk_accuracy(pred.data, targets[:, i].contiguous(), topk=(1, 5)) 31 | stats["top1_acc"].feed(prec1[0]) 32 | stats["top5_acc"].feed(prec5[0]) 33 | 34 | # backward. 35 | loss = self.policy_loss((pred + eps).log(), Variable(targets[:, i])) 36 | stats["loss" + str(i)].feed(loss.data[0]) 37 | total_loss = add_err(total_loss, loss / (i + 1)) 38 | 39 | stats["total_loss"].feed(total_loss.data[0]) 40 | if not self.args.multipred_no_backprop: 41 | total_loss.backward() 42 | -------------------------------------------------------------------------------- /go/python_wrapper.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | //File: python_wrapper.cc 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "../elf/pybind_helper.h" 16 | 17 | #include "game_context.h" 18 | 19 | namespace py = pybind11; 20 | 21 | PYBIND11_MODULE(go_game, m) { 22 | register_common_func(m); 23 | 24 | CONTEXT_REGISTER(GameContext) 25 | .def("GetParams", &GameContext::GetParams) 26 | .def("ShowBoard", &GameContext::ShowBoard); 27 | //.def("ApplyHandicap", &GameContext::ApplyHandicap) 28 | //.def("UndoMove", &GameContext::UndoMove); 29 | 30 | // Also register other objects. 31 | PYCLASS_WITH_FIELDS(m, GameOptions) 32 | .def(py::init<>()); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /go/test_sgf.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #include 10 | #include "sgf.h" 11 | 12 | int main() { 13 | Sgf sgf; 14 | sgf.Load("sample1.sgf"); 15 | cout << sgf.PrintHeader() << endl; 16 | cout << sgf.PrintMainVariation() << endl; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /go/train.lst: -------------------------------------------------------------------------------- 1 | sample1.sgf 2 | 3 | -------------------------------------------------------------------------------- /overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/overview.png -------------------------------------------------------------------------------- /rlpytorch/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from .args_provider import ArgsProvider 8 | from .model_base import Model 9 | from .model_loader import ModelLoader, load_env 10 | from .model_interface import ModelInterface 11 | 12 | from .sampler import Sampler 13 | from .methods import ActorCritic, RNNActorCritic 14 | from .runner import EvalIters, SingleProcessRun 15 | from .trainer import Trainer, Evaluator, LSTMTrainer 16 | 17 | from .methods import add_err, PolicyGradient, DiscountedReward, ValueMatcher 18 | -------------------------------------------------------------------------------- /rlpytorch/args_utils.py: -------------------------------------------------------------------------------- 1 | args_provider.py -------------------------------------------------------------------------------- /rlpytorch/methods/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from .actor_critic import ActorCritic 8 | from .rnn_actor_critic import RNNActorCritic 9 | from .q_learning import Q_learning 10 | from .policy_gradient import PolicyGradient 11 | from .discounted_reward import DiscountedReward 12 | from .value_matcher import ValueMatcher 13 | from .utils import add_err 14 | 15 | -------------------------------------------------------------------------------- /rlpytorch/runner/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from .single_process import SingleProcessRun 8 | # from .multi_process import MultiProcessRun 9 | from .eval_iters import EvalIters 10 | -------------------------------------------------------------------------------- /rlpytorch/sampler/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from .sampler import Sampler 8 | from .sample_methods import sample_multinomial, epsilon_greedy 9 | -------------------------------------------------------------------------------- /rlpytorch/stats/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from .stats import EvalCount, RewardCount, WinRate, Stats 8 | -------------------------------------------------------------------------------- /rlpytorch/trainer/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from .utils import ModelSaver, MultiCounter, topk_accuracy 8 | from .trainer import Trainer, Evaluator 9 | from .lstm_trainer import LSTMTrainer 10 | 11 | -------------------------------------------------------------------------------- /rlpytorch/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from .hist_states import HistState 8 | -------------------------------------------------------------------------------- /rts/.gitignore: -------------------------------------------------------------------------------- 1 | *.gen.h 2 | -------------------------------------------------------------------------------- /rts/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 3.3) 2 | # 3.3 is required. See https://cmake.org/Bug/view.php?id=15414 3 | project(rts) 4 | set(CMAKE_CXX_STANDARD 11) 5 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") 6 | if(NOT CMAKE_BUILD_TYPE) 7 | set(CMAKE_BUILD_TYPE Release) 8 | endif() 9 | set(CMAKE_CXX_FLAGS_DEBUG "-g") 10 | set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native") 11 | 12 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../elf/ ${CMAKE_BINARY_DIR}/elf/) 13 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../vendor/ ${CMAKE_BINARY_DIR}/vendor/) 14 | 15 | # include engine 16 | add_subdirectory(engine) 17 | 18 | # compile the game itself 19 | set(GAME_DIR "${CMAKE_CURRENT_SOURCE_DIR}/game_MC" CACHE PATH "Directory to the game implementation, e.g. ../game_MC") 20 | add_subdirectory(${GAME_DIR} ${CMAKE_BINARY_DIR}/minirts) 21 | set_target_properties(minirts PROPERTIES 22 | LIBRARY_OUTPUT_DIRECTORY "${GAME_DIR}" 23 | ) 24 | 25 | # compile the backend with this game 26 | add_subdirectory(backend) 27 | set_target_properties(minirts-backend PROPERTIES 28 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" 29 | ) 30 | -------------------------------------------------------------------------------- /rts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/__init__.py -------------------------------------------------------------------------------- /rts/backend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | file(GLOB SOURCES *.cc) 3 | add_executable(minirts-backend ${SOURCES}) 4 | target_link_libraries(minirts-backend 5 | minirts-game 6 | concurrentqueue json websocketpp) 7 | target_include_directories(minirts-backend PRIVATE ${GAME_DIR}) 8 | -------------------------------------------------------------------------------- /rts/backend/README.md: -------------------------------------------------------------------------------- 1 | # BackEnd 2 | 3 | Compilation 4 | ======== 5 | Note that due to [this](https://github.com/nlohmann/json#supported-compilers), only GCC >= 4.9 is supported here. 6 | 7 | First compile `./rts/game_MC` (or other two games), then compile this folder by 8 | ```bash 9 | make GAME_DIR="../game_MC" 10 | ``` 11 | to get an standalone executable file. 12 | -------------------------------------------------------------------------------- /rts/backend/save2json.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #ifndef _SAVE2JSON_H_ 10 | #define _SAVE2JSON_H_ 11 | 12 | #include "engine/common.h" 13 | #include "json.hpp" 14 | 15 | using json = nlohmann::json; 16 | 17 | class RTSMap; 18 | class Player; 19 | class Unit; 20 | class Bullet; 21 | class CmdReceiver; 22 | 23 | class save2json { 24 | public: 25 | static void SetTick(Tick tick, json *game); 26 | static void SetWinner(PlayerId id, json *game); 27 | static void SetTermination(bool t, json *game); 28 | static void SetGameCounter(int game_counter, json *game); 29 | static void SetPlayerId(PlayerId id, json *game); 30 | static void SetSpectator(bool is_spectator, json *game); 31 | 32 | static void Save(const RTSMap& m, json *game); 33 | static void SaveStats(const Player& player, json *game); 34 | static void SavePlayerMap(const Player& player, json *game); 35 | // static void Save(const AI &bot, json *game); 36 | static void Save(const Unit& unit, const CmdReceiver *receiver, json *game); 37 | static void Save(const Bullet& bullet, json *game); 38 | static void SaveCmd(const CmdReceiver &receiver, PlayerId player_id, json *game); 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /rts/engine/.ropeproject/globalnames: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/engine/.ropeproject/globalnames -------------------------------------------------------------------------------- /rts/engine/.ropeproject/history: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/engine/.ropeproject/history -------------------------------------------------------------------------------- /rts/engine/.ropeproject/objectdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/engine/.ropeproject/objectdb -------------------------------------------------------------------------------- /rts/engine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMD_COMPILE_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/compile_cmds.py" 2 | CACHE STRING "Path to the python script to compile commands.") 3 | 4 | function(add_rts_command_gen DEF NAME) 5 | # use the specified python, if any 6 | if (NOT PYTHON_EXECUTABLE) 7 | set(_PYTHON_EXE python) 8 | else() 9 | set(_PYTHON_EXE "${PYTHON_EXECUTABLE}") 10 | endif() 11 | 12 | add_custom_command( 13 | OUTPUT ${DEF}.gen.h 14 | COMMAND ${_PYTHON_EXE} ${CMD_COMPILE_SCRIPT} --def_file ${DEF} --name ${NAME} 15 | COMMENT "Running compile_cmds.py on ${DEF}" 16 | VERBATIM 17 | DEPENDS ${DEF}.def 18 | ) 19 | set_source_files_properties(${DEF}.gen.h PROPERTIES GENERATED TRUE) 20 | endfunction() 21 | 22 | function(prepend_each OUTPUT PREFIX) 23 | set(ret "") 24 | foreach(f ${ARGN}) 25 | list(APPEND ret "${PREFIX}/${f}") 26 | endforeach() 27 | set(${OUTPUT} "${ret}" PARENT_SCOPE) 28 | endfunction() 29 | add_rts_command_gen(${CMAKE_CURRENT_SOURCE_DIR}/cmd engine) 30 | add_rts_command_gen(${CMAKE_CURRENT_SOURCE_DIR}/cmd_specific engine_specific) 31 | 32 | # Engine and game depend on each other 33 | # But we're using INTERFACE target, sources will be built together in the end, so it can work 34 | file(GLOB RTS_ENGINE_SOURCES *.cc) 35 | add_library(minirts-engine INTERFACE) 36 | target_sources(minirts-engine INTERFACE ${RTS_ENGINE_SOURCES}) 37 | target_include_directories(minirts-engine INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/../) 38 | 39 | add_custom_target(minirts-engine-headers DEPENDS 40 | ${CMAKE_CURRENT_SOURCE_DIR}/cmd.gen.h 41 | ${CMAKE_CURRENT_SOURCE_DIR}/cmd_specific.gen.h) 42 | add_dependencies(minirts-engine minirts-engine-headers) 43 | -------------------------------------------------------------------------------- /rts/engine/README.md: -------------------------------------------------------------------------------- 1 | ## RTS engine 2 | 3 | This folder cannot compile independently, and will be included when compiling specific games (e.g., `./rts/game_MC`). 4 | 5 | A better way is to compile the RTS engine into a library for specific game to use. We will do it later. 6 | -------------------------------------------------------------------------------- /rts/engine/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from .common_loader import CommonLoader 8 | -------------------------------------------------------------------------------- /rts/engine/ai.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #include "ai.h" 10 | #include "float.h" 11 | 12 | -------------------------------------------------------------------------------- /rts/engine/ai.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "cmd_receiver.h" 12 | #include "game_state.h" 13 | #include "elf/ai.h" 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | template 21 | class AIFactory { 22 | public: 23 | using RegFunc = function; 24 | 25 | // Factory method given specification. 26 | static AI *CreateAI(const string &name, const string& spec) { 27 | lock_guard lock(_mutex); 28 | auto it = _factories.find(name); 29 | if (it == _factories.end()) return nullptr; 30 | return it->second(spec); 31 | } 32 | static void RegisterAI(const string &name, RegFunc reg_func) { 33 | lock_guard lock(_mutex); 34 | _factories.insert(make_pair(name, reg_func)); 35 | } 36 | private: 37 | static map _factories; 38 | static mutex _mutex; 39 | }; 40 | 41 | template 42 | map> AIFactory::_factories; 43 | 44 | template 45 | mutex AIFactory::_mutex; 46 | 47 | 48 | -------------------------------------------------------------------------------- /rts/engine/cmd.def: -------------------------------------------------------------------------------- 1 | CMD_START(100); 2 | 3 | CMD_IMMEDIATE(TacticalMove, PointF, p); 4 | CMD_IMMEDIATE(Create, UnitType, build_type, PointF, p, PlayerId, player_id, int, resource_used = 0); 5 | CMD_IMMEDIATE(Remove); 6 | CMD_IMMEDIATE(EmitBullet, UnitId, target, PointF, p, int, att, float, speed); 7 | CMD_IMMEDIATE(SaveMap, std::string, s); 8 | CMD_IMMEDIATE(LoadMap, std::string, s); 9 | CMD_IMMEDIATE(RandomSeed, uint64_t, seed); 10 | CMD_IMMEDIATE(Comment, std::string, comment); 11 | CMD_IMMEDIATE(CDStart, CDType, cd_type); 12 | 13 | -------------------------------------------------------------------------------- /rts/engine/cmd_specific.def: -------------------------------------------------------------------------------- 1 | CMD_START(200); 2 | 3 | CMD_DURATIVE(Attack, UnitId, target); 4 | CMD_DURATIVE(Move, PointF, p); 5 | CMD_DURATIVE(Build, UnitType, build_type, PointF, p = PointF(), int, state = 0); 6 | CMD_DURATIVE(Gather, UnitId, base, UnitId, resource, int, state = 0); 7 | CMD_IMMEDIATE(MeleeAttack, UnitId, target, int, att); 8 | 9 | CMD_IMMEDIATE(OnDeadUnit, UnitId, target); 10 | CMD_IMMEDIATE(Harvest, UnitId, target, int, delta); 11 | CMD_IMMEDIATE(ChangePlayerResource, PlayerId, player_id, int, delta); 12 | -------------------------------------------------------------------------------- /rts/engine/game_new.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /rts/engine/gamedef.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #include "gamedef.h" 10 | 11 | UnitTemplate _C(int cost, int hp, int defense, float speed, int att, int att_r, int vis_r, 12 | const vector &cds, const vector &l, UnitAttr attr) { 13 | 14 | UnitTemplate res; 15 | res._build_cost = cost; 16 | auto &p = res._property; 17 | p._hp = p._max_hp = hp; 18 | p._speed = speed; 19 | p._def = defense; 20 | p._att = att; 21 | p._attr = attr; 22 | p._att_r = att_r; 23 | p._vis_r = vis_r; 24 | for (int i = 0; i < NUM_COOLDOWN; ++i) { 25 | p._cds[i].Set(cds[i]); 26 | } 27 | 28 | for (const auto &i : l) { 29 | res._allowed_cmds.insert(i); 30 | } 31 | 32 | return res; 33 | }; 34 | -------------------------------------------------------------------------------- /rts/engine/replay_loader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "cmd_receiver.h" 12 | #include 13 | 14 | class RTSState; 15 | 16 | class ReplayLoader { 17 | public: 18 | struct Action { 19 | vector cmds; 20 | vector ui_cmds; 21 | bool restart = false; 22 | string new_state; 23 | }; 24 | 25 | bool Load(const string& filename); 26 | void SendReplay(Tick tick, Action *actions); 27 | void Relocate(Tick tick); 28 | 29 | int GetLoadedReplaySize() const { return _loaded_replay.size(); } 30 | int GetLoadedReplayLastTick() const { return _loaded_replay.back()->tick(); } 31 | 32 | private: 33 | // Idx for the next replay to send to the queue. 34 | unsigned int _next_replay_idx = 0; 35 | vector _loaded_replay; 36 | }; 37 | 38 | class Replayer : public ReplayLoader { 39 | public: 40 | using Action = typename ReplayLoader::Action; 41 | Replayer(const string &filename) { ReplayLoader::Load(filename); } 42 | virtual bool Act(const RTSState &s, Action *a, const atomic_bool *); 43 | bool GameEnd() { return true; } 44 | 45 | virtual ~Replayer() { } 46 | }; 47 | 48 | -------------------------------------------------------------------------------- /rts/engine/ui_cmd.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "common.h" 12 | 13 | custom_enum(UICtrlType, UI_SLIDEBAR, UI_FASTER_SIMULATION, UI_SLOWER_SIMULATION, UI_CYCLEPLAYER, TOGGLE_GAME_PAUSE); 14 | 15 | struct UICmd { 16 | UICtrlType cmd; 17 | float arg2; 18 | 19 | UICmd() { } 20 | 21 | static UICmd GetUIFaster() { UICmd cmd; cmd.cmd = UI_FASTER_SIMULATION; return cmd; } 22 | static UICmd GetUISlower() { UICmd cmd; cmd.cmd = UI_SLOWER_SIMULATION; return cmd; } 23 | // Percentage, 0-100.0 24 | static UICmd GetUISlideBar(float percent) { UICmd cmd; cmd.cmd = UI_SLIDEBAR; cmd.arg2 = percent; return cmd; } 25 | static UICmd GetUICyclePlayer() { UICmd cmd; cmd.cmd = UI_CYCLEPLAYER; return cmd; } 26 | static UICmd GetToggleGamePause() { UICmd cmd; cmd.cmd = TOGGLE_GAME_PAUSE; return cmd; } 27 | 28 | std::string PrintInfo() const { 29 | //case UI_SLIDEBAR: oo << make_string("percent:", arg2); break; 30 | return ""; 31 | } 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /rts/engine/unit.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #include "unit.h" 10 | #include 11 | 12 | // ----------------------- Unit definition ---------------------- 13 | PlayerId Unit::GetPlayerId() const { 14 | return Player::ExtractPlayerId(_id); 15 | } 16 | 17 | string Unit::PrintInfo(const RTSMap&) const { 18 | // Print the information for the unit. 19 | stringstream ss; 20 | ss << "U[" << Player::ExtractPlayerId(_id) << ":" << _id << "], @(" << _p.x << ", " << _p.y << "), "; 21 | ss << _type << ", H " << _property._hp << "/" << _property._max_hp << ", B " << _built_since << " A" << _property._att << " D" << _property._def << " | "; 22 | for (int j = 0; j < NUM_COOLDOWN; j++) { 23 | const auto &cd = _property.CD((CDType)j); 24 | ss << (CDType)j << ": " << cd._cd << "/" << cd._last << " "; 25 | } 26 | return ss.str(); 27 | } 28 | 29 | string Unit::Draw(Tick tick) const { 30 | // Draw the unit. 31 | return make_string("c", Player::ExtractPlayerId(_id), _last_p, _p, _type) + " " + _property.Draw(tick); 32 | } 33 | -------------------------------------------------------------------------------- /rts/frontend/imgs/14SAF.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/14SAF.png -------------------------------------------------------------------------------- /rts/frontend/imgs/2ebyiko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/2ebyiko.png -------------------------------------------------------------------------------- /rts/frontend/imgs/2eki549.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/2eki549.png -------------------------------------------------------------------------------- /rts/frontend/imgs/Actor1_zps2890a1cd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/Actor1_zps2890a1cd.png -------------------------------------------------------------------------------- /rts/frontend/imgs/Actor2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/Actor2.png -------------------------------------------------------------------------------- /rts/frontend/imgs/Christmas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/Christmas.png -------------------------------------------------------------------------------- /rts/frontend/imgs/People3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/People3.png -------------------------------------------------------------------------------- /rts/frontend/imgs/People4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/People4.png -------------------------------------------------------------------------------- /rts/frontend/imgs/RTPkaihenn18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/RTPkaihenn18.png -------------------------------------------------------------------------------- /rts/frontend/imgs/Spacece.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/Spacece.png -------------------------------------------------------------------------------- /rts/frontend/imgs/Sprites-Lunarea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/Sprites-Lunarea.png -------------------------------------------------------------------------------- /rts/frontend/imgs/barracks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/barracks.png -------------------------------------------------------------------------------- /rts/frontend/imgs/base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/base.png -------------------------------------------------------------------------------- /rts/frontend/imgs/building.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/building.png -------------------------------------------------------------------------------- /rts/frontend/imgs/char_sample_zpsef814b4c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/char_sample_zpsef814b4c.png -------------------------------------------------------------------------------- /rts/frontend/imgs/items.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/items.png -------------------------------------------------------------------------------- /rts/frontend/imgs/items_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/items_12.png -------------------------------------------------------------------------------- /rts/frontend/imgs/mineral1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/mineral1.png -------------------------------------------------------------------------------- /rts/frontend/imgs/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/frontend/imgs/tiles.png -------------------------------------------------------------------------------- /rts/frontend/minirts.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | MiniRTS 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /rts/game_CF/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_rts_command_gen(${CMAKE_CURRENT_SOURCE_DIR}/cmd_specific cf_specific) 2 | 3 | # don't build python stuff together with the game, so we list the sources manually 4 | set(SOURCES ai.cc cmd_specific.cc gamedef.cc cf_rule_actor.cc) 5 | prepend_each(SOURCES ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCES}) 6 | 7 | add_library(minirts-game INTERFACE) 8 | target_sources(minirts-game INTERFACE ${SOURCES}) 9 | target_link_libraries(minirts-game INTERFACE elf minirts-engine) 10 | 11 | add_custom_target(minirts-game-headers DEPENDS 12 | ${CMAKE_CURRENT_SOURCE_DIR}/cmd_specific.gen.h) 13 | add_dependencies(minirts-game minirts-game-headers) 14 | 15 | # python libraries 16 | pybind11_add_module(minirts python_wrapper.cc wrapper_callback.cc) 17 | target_link_libraries(minirts PRIVATE minirts-game) 18 | -------------------------------------------------------------------------------- /rts/game_CF/cf_rule_actor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #ifndef _CF_RULE_ACTOR_H_ 10 | #define _CF_RULE_ACTOR_H_ 11 | 12 | #include "engine/rule_actor.h" 13 | #include "engine/cmd.h" 14 | #include "cmd_specific.gen.h" 15 | 16 | class CFRuleActor : public RuleActor { 17 | public: 18 | CFRuleActor(){ } 19 | // Act by a state array, used by Capture the flag 20 | bool FlagActByState(const GameEnv &env, const vector& state, AssignedCmds *assigned_cmds); 21 | // Determine state array for FlagSimpleAI 22 | bool GetFlagActSimpleState(const GameEnv &env, vector* state); 23 | }; 24 | #endif 25 | -------------------------------------------------------------------------------- /rts/game_CF/cmd_specific.def: -------------------------------------------------------------------------------- 1 | CMD_START(2000); 2 | 3 | # Set handicap level for Captrue the flag. 4 | CMD_IMMEDIATE(FlagSetHandicap, int, level); 5 | 6 | # Set up map for capture the flag. 7 | CMD_IMMEDIATE(CaptureFlagGameStart, int, num_obstacles); 8 | 9 | # Ask the current unit to pick up the flag. 10 | CMD_IMMEDIATE(PickUpFlag, UnitId, flag); 11 | 12 | # If flag is carried back to base, score a point. 13 | CMD_IMMEDIATE(ScoreFlag); 14 | 15 | # Athelete is revived near base after certain ticks, if killed. 16 | CMD_IMMEDIATE(ReviveAthlete, PlayerId, player_id); 17 | 18 | # Durative action to get the flag. Will move towards the flag until it can be picked up. 19 | CMD_DURATIVE(GetFlag, UnitId, flag); 20 | 21 | # Durative action to score the flag. Will carry the flag back to base and score the flag. 22 | CMD_DURATIVE(EscortFlagToBase); 23 | -------------------------------------------------------------------------------- /rts/game_CF/wrapper_callback.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "elf/comm_template.h" 12 | #include "elf/pybind_interface.h" 13 | #include "engine/game.h" 14 | 15 | #include "python_options.h" 16 | 17 | class WrapperCallbacks { 18 | private: 19 | int _game_idx; 20 | const ContextOptions &_context_options; 21 | const PythonOptions &_options; 22 | 23 | Context::Comm *_comm; 24 | std::vector> _ai_comms; 25 | AI *_ai; 26 | 27 | float _latest_start; 28 | void initialize_ai_comm(Context::AIComm &ai_comm); 29 | 30 | public: 31 | explicit WrapperCallbacks(int game_idx, const ContextOptions &context_options, const PythonOptions &options, Context::Comm *comm) 32 | : _game_idx(game_idx), _context_options(context_options), _options(options), _comm(comm), _ai(nullptr) { 33 | } 34 | 35 | void OnGameOptions(RTSGameOptions *rts_options); 36 | void OnGameInit(RTSGame *game, const std::map *more_params); 37 | void OnEpisodeStart(int k, std::mt19937 *rng, RTSGame *game); 38 | }; 39 | -------------------------------------------------------------------------------- /rts/game_MC/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_rts_command_gen(${CMAKE_CURRENT_SOURCE_DIR}/cmd_specific minirts_specific) 2 | 3 | # don't build python stuff together with the game, so we list the sources manually 4 | set(SOURCES ai.cc game_action.cc trainable_ai.cc cmd_specific.cc gamedef.cc mc_rule_actor.cc state_feature.cc) 5 | prepend_each(SOURCES ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCES}) 6 | 7 | add_library(minirts-game INTERFACE) 8 | target_sources(minirts-game INTERFACE ${SOURCES}) 9 | target_link_libraries(minirts-game INTERFACE elf minirts-engine) 10 | 11 | add_custom_target(minirts-game-headers DEPENDS 12 | ${CMAKE_CURRENT_SOURCE_DIR}/cmd_specific.gen.h) 13 | add_dependencies(minirts-game minirts-game-headers) 14 | 15 | # python libraries 16 | pybind11_add_module(minirts python_wrapper.cc wrapper_callback.cc) 17 | target_link_libraries(minirts PRIVATE minirts-game) 18 | -------------------------------------------------------------------------------- /rts/game_MC/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/game_MC/__init__.py -------------------------------------------------------------------------------- /rts/game_MC/ai.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/game_MC/ai.cc -------------------------------------------------------------------------------- /rts/game_MC/ai.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "engine/cmd_util.h" 12 | #include "engine/cmd_interface.h" 13 | #include "engine/game_state.h" 14 | #include "elf/ai.h" 15 | #include "elf/mcts.h" 16 | #include "game_action.h" 17 | #include "python_options.h" 18 | #define NUM_RES_SLOT 5 19 | 20 | using Comm = Context::Comm; 21 | using AIComm = AICommT; 22 | using Data = typename AIComm::Data; 23 | 24 | using AIWithComm = elf::AIWithCommT; 25 | using AI = elf::AI_T; 26 | 27 | struct ReducedState { 28 | vector state; 29 | int action; 30 | }; 31 | 32 | struct ReducedPred : public mcts::NodeResponseT { 33 | void SetPiAndV(const vector& new_pi, float new_v) { 34 | this->pi.resize(new_pi.size()); 35 | for (size_t i = 0; i < new_pi.size(); ++i) { 36 | this->pi[i].first = i; 37 | this->pi[i].second = new_pi[i]; 38 | } 39 | this->value = new_v; 40 | } 41 | }; 42 | -------------------------------------------------------------------------------- /rts/game_MC/cmd_specific.def: -------------------------------------------------------------------------------- 1 | CMD_START(1000); 2 | 3 | # Generate a game map, with base and resource location, resource amount, and number of obstacles. 4 | CMD_IMMEDIATE(GenerateMap, int, num_obstacles, int, init_resource); 5 | 6 | # Generate some units randomly on the map. 7 | CMD_IMMEDIATE(GenerateUnit); 8 | 9 | # Start the game from a predefined setup. Should be called after GenerateMap and GenerateUnit 10 | CMD_IMMEDIATE(GameStartSpecific); 11 | -------------------------------------------------------------------------------- /rts/game_MC/game_action.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "engine/game_action.h" 12 | #include "mc_rule_actor.h" 13 | 14 | class RTSMCAction : public RTSAction { 15 | private: 16 | enum ActionType { STATE9 = 0, SIMPLE = 1, HIT_AND_RUN = 2, CMD_INPUT = 3 }; 17 | 18 | public: 19 | RTSMCAction() : _type(CMD_INPUT), _action(-1) { } 20 | 21 | void SetState9(int action) { 22 | _type = STATE9; 23 | _action = action; 24 | } 25 | 26 | void SetSimpleAI() { _type = SIMPLE; } 27 | void SetHitAndRunAI() { _type = HIT_AND_RUN; } 28 | 29 | void SetUnitCmds(const std::vector &unit_cmds) { 30 | _type = CMD_INPUT; 31 | _unit_cmds = unit_cmds; 32 | } 33 | 34 | bool Send(const GameEnv &env, CmdReceiver &receiver); 35 | 36 | protected: 37 | ActionType _type; 38 | int _action; 39 | std::vector _unit_cmds; 40 | }; 41 | 42 | -------------------------------------------------------------------------------- /rts/game_MC/mc_rule_actor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #ifndef _MC_RULE_ACTOR_H_ 10 | #define _MC_RULE_ACTOR_H_ 11 | 12 | #include "engine/rule_actor.h" 13 | 14 | class MCRuleActor : public RuleActor { 15 | public: 16 | MCRuleActor(){ } 17 | // Act by a state array, used by MiniRTS 18 | bool ActByState(const GameEnv &env, const vector& state, string *state_string, AssignedCmds *assigned_cmds); 19 | // Act by a state array for each unit, used by MiniRTS 20 | bool ActByState2(const GameEnv &env, const vector& state, string *state_string, AssignedCmds *assigned_cmds); 21 | // Act by a state array for each region, used by MiniRTS 22 | //bool ActByRegionalState(const GameEnv &env, const Reply &reply, string *state_string, AssignedCmds *assigned_cmds); 23 | 24 | // Determine state array for SimpleAI 25 | bool GetActSimpleState(vector* state); 26 | // Determine state array for HitAndRunAI 27 | 28 | bool GetActHitAndRunState(vector* state); 29 | // [REGION_MAX_RANGE_X][REGION_MAX_RANGE_Y][REGION_RANGE_CHANNEL] 30 | bool ActWithMap(const GameEnv &env, const vector>>& action_map, string *state_string, AssignedCmds *assigned_cmds); 31 | }; 32 | #endif 33 | -------------------------------------------------------------------------------- /rts/game_MC/trainable_ai.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "ai.h" 13 | #include "elf/circular_queue.h" 14 | 15 | class TrainedAI : public AIWithComm { 16 | public: 17 | using State = AIWithComm::State; 18 | using Action = AIWithComm::Action; 19 | using Data = typename AIWithComm::Data; 20 | 21 | TrainedAI() : _respect_fow(true), _recent_states(1) { } 22 | TrainedAI(const AIOptions &opt) 23 | : AIWithComm(opt.name), _respect_fow(opt.fow), _recent_states(opt.num_frames_in_state) { 24 | for (auto &v : _recent_states.v()) v.clear(); 25 | } 26 | 27 | bool GameEnd() override; 28 | 29 | protected: 30 | const bool _respect_fow; 31 | 32 | // History to send. 33 | CircularQueue> _recent_states; 34 | 35 | void compute_state(std::vector *state); 36 | 37 | // Feature extraction. 38 | void extract(const State &, Data *data) override; 39 | bool handle_response(const State &, const Data &data, RTSMCAction *a) override; 40 | }; 41 | 42 | -------------------------------------------------------------------------------- /rts/game_MC/wrapper_callback.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "elf/comm_template.h" 12 | #include "elf/pybind_interface.h" 13 | 14 | #include "engine/game.h" 15 | #include "engine/wrapper_template.h" 16 | #include "python_options.h" 17 | #include "ai.h" 18 | 19 | using RTSGame = elf::GameBaseT;; 20 | 21 | class WrapperCallbacks { 22 | private: 23 | int _game_idx; 24 | const ContextOptions &_context_options; 25 | const PythonOptions &_options; 26 | 27 | Context::Comm *_comm; 28 | 29 | std::vector> _ai_comms; 30 | 31 | void initialize_ai_comm(Context::AIComm &ai_comm, const std::map *more_params); 32 | 33 | public: 34 | explicit WrapperCallbacks(int game_idx, const ContextOptions &context_options, const PythonOptions &options, Context::Comm *comm) 35 | : _game_idx(game_idx), _context_options(context_options), _options(options), _comm(comm) { 36 | } 37 | 38 | void OnGameOptions(RTSGameOptions *rts_options); 39 | void OnGameInit(RTSGame *game, const std::map *more_params); 40 | 41 | void OnEpisodeStart(int k, std::mt19937 *rng, RTSGame *game); 42 | }; 43 | -------------------------------------------------------------------------------- /rts/game_TD/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_rts_command_gen(${CMAKE_CURRENT_SOURCE_DIR}/cmd_specific td_specific) 2 | 3 | # don't build python stuff together with the game, so we list the sources manually 4 | set(SOURCES ai.cc cmd_specific.cc gamedef.cc td_rule_actor.cc) 5 | prepend_each(SOURCES ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCES}) 6 | 7 | add_library(minirts-game INTERFACE) 8 | target_sources(minirts-game INTERFACE ${SOURCES}) 9 | target_link_libraries(minirts-game INTERFACE elf minirts-engine) 10 | 11 | add_custom_target(minirts-game-headers DEPENDS 12 | ${CMAKE_CURRENT_SOURCE_DIR}/cmd_specific.gen.h) 13 | add_dependencies(minirts-game minirts-game-headers) 14 | 15 | # python libraries 16 | pybind11_add_module(minirts python_wrapper.cc wrapper_callback.cc) 17 | target_link_libraries(minirts PRIVATE minirts-game) 18 | -------------------------------------------------------------------------------- /rts/game_TD/cmd_specific.def: -------------------------------------------------------------------------------- 1 | CMD_START(3000); 2 | 3 | # Set up map for tower defense. 4 | CMD_IMMEDIATE(TowerDefenseGameStart); 5 | 6 | # Wave of enemies appear in bottom right of map and move through the maze to attack your base in the top left. 7 | CMD_IMMEDIATE(TowerDefenseWaveStart, int, wave); 8 | 9 | # Upgrade tower's range. 10 | CMD_IMMEDIATE(UpgradeTowerRange, UnitId, target_id, int, price, PlayerId, player_id); 11 | 12 | # Upgrade tower's attack. 13 | CMD_IMMEDIATE(UpgradeTowerAttack, UnitId, target_id, int, price, PlayerId, player_id); 14 | 15 | # Build a tower at current location. 16 | CMD_DURATIVE(BuildTower, PointF, p, int, price, PlayerId, player_id); 17 | -------------------------------------------------------------------------------- /rts/game_TD/td_rule_actor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #ifndef _TD_RULE_ACTOR_H_ 10 | #define _TD_RULE_ACTOR_H_ 11 | 12 | #include "engine/rule_actor.h" 13 | #include "engine/cmd.h" 14 | #include "cmd_specific.gen.h" 15 | 16 | class TDRuleActor : public RuleActor { 17 | public: 18 | TDRuleActor(){ } 19 | // Act by a state array, used by Capture the flag // Act by a state array, used by Tower defense 20 | bool TowerDefenseActByState(const GameEnv &env, int state, AssignedCmds *assigned_cmds); 21 | // Determine state array for TowerDefenseSimpleAI 22 | bool ActTowerDefenseSimple(const GameEnv &env, AssignedCmds *assigned_cmds); 23 | // Built-In action for Tower Defense environment. 24 | bool ActTowerDefenseBuiltIn(const GameEnv&, AssignedCmds *assigned_cmds); 25 | }; 26 | #endif 27 | -------------------------------------------------------------------------------- /rts/game_TD/wrapper_callback.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "elf/comm_template.h" 12 | #include "elf/pybind_interface.h" 13 | 14 | #include "engine/game.h" 15 | #include "python_options.h" 16 | 17 | class WrapperCallbacks { 18 | private: 19 | int _game_idx; 20 | const ContextOptions &_context_options; 21 | const PythonOptions &_options; 22 | 23 | Context::Comm *_comm; 24 | 25 | std::vector> _ai_comms; 26 | 27 | AI *_ai; 28 | 29 | 30 | float _latest_start; 31 | void initialize_ai_comm(Context::AIComm &ai_comm); 32 | 33 | public: 34 | explicit WrapperCallbacks(int game_idx, const ContextOptions &context_options, const PythonOptions &options, Context::Comm *comm) 35 | : _game_idx(game_idx), _context_options(context_options), _options(options), _comm(comm), _ai(nullptr) { 36 | } 37 | 38 | void OnGameOptions(RTSGameOptions *rts_options); 39 | void OnGameInit(RTSGame *game); 40 | void OnEpisodeStart(int k, std::mt19937 *rng, RTSGame *game); 41 | }; 42 | -------------------------------------------------------------------------------- /rts/rts_intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/ELF/1f790173095cd910976d9f651b80beb872ec5d12/rts/rts_intro.png -------------------------------------------------------------------------------- /selfplay.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | #!/usr/bin/env python 8 | # -*- coding: utf-8 -*- 9 | 10 | import argparse 11 | from datetime import datetime 12 | 13 | import sys 14 | import os 15 | 16 | from rlpytorch import * 17 | 18 | if __name__ == '__main__': 19 | verbose = False 20 | 21 | trainer = Trainer(verbose=verbose) 22 | runner = SingleProcessRun() 23 | evaluator = Evaluator(stats=False, verbose=verbose) 24 | env, all_args = load_env(os.environ, trainer=trainer, runner=runner, evaluator=evaluator) 25 | 26 | GC = env["game"].initialize_selfplay() 27 | 28 | model = env["model_loaders"][0].load_model(GC.params) 29 | env["mi"].add_model("model", model, opt=True) 30 | env["mi"].add_model("actor", model, copy=True, cuda=all_args.gpu is not None, gpu_id=all_args.gpu) 31 | 32 | trainer.setup(sampler=env["sampler"], mi=env["mi"], rl_method=env["method"]) 33 | evaluator.setup(sampler=env["sampler"], mi=env["mi"].clone(gpu=all_args.gpu)) 34 | 35 | if not all_args.actor_only: 36 | GC.reg_callback("train1", trainer.train) 37 | GC.reg_callback("actor1", trainer.actor) 38 | GC.reg_callback("actor0", evaluator.actor) 39 | 40 | def summary(i): 41 | trainer.episode_summary(i) 42 | evaluator.episode_summary(i) 43 | 44 | def start(i): 45 | trainer.episode_start(i) 46 | evaluator.episode_start(i) 47 | 48 | runner.setup(GC, episode_summary=summary, episode_start=start) 49 | runner.run() 50 | 51 | -------------------------------------------------------------------------------- /selfplay_aivsai.sh: -------------------------------------------------------------------------------- 1 | game=./rts/game_MC/game model=actor_critic model_file=./rts/game_MC/model python3 eval_selfplay_aivsai.py --num_games 1024 --batchsize 128 --tqdm --players "fs=50,type=AI_NN;fs=50,type=AI_NN" --eval0_stats winrate --eval1_stats winrate --additional_labels id,last_terminal,seq --load0 /home/yuandong/private_models/model-winrate-80.0-357800.bin --load1 /home/yuandong/private_models/model-minirts-selfplay-0.5old-0.5simpleai.bin --gpu 2 --T 1 --shuffle_player "$@" 2 | -------------------------------------------------------------------------------- /selfplay_minirts.sh: -------------------------------------------------------------------------------- 1 | MODEL=$1 2 | 3 | game=./rts/game_MC/game model_file=./rts/game_MC/model model=actor_critic python3 selfplay.py --num_games 1024 --batchsize 128 --tqdm --players "fs=50,type=AI_NN;fs=50,type=AI_NN" --trainer_stats winrate --additional_labels id,last_terminal,seq --load ${MODEL} --gpu 2 --T 20 --shuffle_player 4 | -------------------------------------------------------------------------------- /train.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | #!/usr/bin/env python 8 | # -*- coding: utf-8 -*- 9 | 10 | from datetime import datetime 11 | import sys 12 | import os 13 | 14 | from rlpytorch import * 15 | 16 | if __name__ == '__main__': 17 | trainer = Trainer() 18 | runner = SingleProcessRun() 19 | env, all_args = load_env(os.environ, trainer=trainer, runner=runner) 20 | 21 | GC = env["game"].initialize() 22 | 23 | model = env["model_loaders"][0].load_model(GC.params) 24 | env["mi"].add_model("model", model, opt=True) 25 | env["mi"].add_model("actor", model, copy=True, cuda=all_args.gpu is not None, gpu_id=all_args.gpu) 26 | 27 | trainer.setup(sampler=env["sampler"], mi=env["mi"], rl_method=env["method"]) 28 | 29 | GC.reg_callback("train", trainer.train) 30 | GC.reg_callback("actor", trainer.actor) 31 | runner.setup(GC, episode_summary=trainer.episode_summary, 32 | episode_start=trainer.episode_start) 33 | 34 | runner.run() 35 | 36 | -------------------------------------------------------------------------------- /train_atari.sh: -------------------------------------------------------------------------------- 1 | ROM=$1 2 | GPU=$2 3 | 4 | game=./atari/game model=actor_critic model_file=./atari/model python3 train.py --rom_file $ROM --batchsize 4 --freq_update 1 --num_games 16 --tqdm --gpu $GPU --trainer_stats rewards --additional_labels id,last_terminal --keys_in_reply V,rv 5 | -------------------------------------------------------------------------------- /train_df.sh: -------------------------------------------------------------------------------- 1 | game=./go/game model=df_policy model_file=./go/df_model python3 train.py --batchsize 128 --freq_update 1 --num_games 512 --T 1 --tqdm --list_file /home/yuandong/local/go/go_gogod/train.lst --trainer_stats rewards "$@" 2 | -------------------------------------------------------------------------------- /train_lstm.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-present, Facebook, Inc. 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | #!/usr/bin/env python 8 | # -*- coding: utf-8 -*- 9 | 10 | import argparse 11 | from datetime import datetime 12 | 13 | import sys 14 | import os 15 | 16 | from rlpytorch import LSTMTrainer, Sampler, SingleProcessRun, load_env, ModelLoader, ArgsProvider, ModelInterface 17 | 18 | if __name__ == '__main__': 19 | trainer = LSTMTrainer() 20 | runner = SingleProcessRun() 21 | env, all_args = load_env(os.environ, trainer=trainer, runner=runner) 22 | 23 | GC = env["game"].initialize() 24 | 25 | model = env["model_loaders"][0].load_model(GC.params) 26 | mi = ModelInterface() 27 | mi.add_model("model", model, optim_params={ "lr" : 0.001}) 28 | mi.add_model("actor", model, copy=True, cuda=all_args.gpu is not None, gpu_id=all_args.gpu) 29 | 30 | trainer.setup(sampler=env["sampler"], mi=mi, rl_method=env["method"]) 31 | 32 | GC.reg_callback("train", trainer.train) 33 | GC.reg_callback("actor", trainer.actor) 34 | runner.setup(GC, episode_summary=trainer.episode_summary, 35 | episode_start=trainer.episode_start) 36 | 37 | runner.run() 38 | 39 | -------------------------------------------------------------------------------- /train_minirts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | game=./rts/game_MC/game model=actor_critic model_file=./rts/game_MC/model python3 train.py --batchsize 128 --freq_update 1 --players "type=AI_NN,fs=50,args=backup/AI_SIMPLE|start/500|decay/0.99;type=AI_SIMPLE,fs=20" --num_games 1024 --tqdm --T 20 --additional_labels id,last_terminal --trainer_stats winrate --keys_in_reply V "$@" 4 | -------------------------------------------------------------------------------- /train_minirts_unitcmd.sh: -------------------------------------------------------------------------------- 1 | game=./rts/game_MC/game model=actor_critic model_file=./rts/game_MC/model_unit_cmd python3 train.py --batchsize 128 --freq_update 1 --players "type=AI_NN,fs=50,args=backup/AI_SIMPLE|start/500|decay/0.99;type=AI_SIMPLE,fs=20" --num_games 1024 --tqdm --T 20 --additional_labels id,last_terminal --trainer_stats winrate "$@" 2 | -------------------------------------------------------------------------------- /vendor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library(asio INTERFACE) 3 | target_include_directories(asio SYSTEM INTERFACE 4 | $ 5 | ) 6 | 7 | add_library(websocketpp INTERFACE) 8 | target_include_directories(websocketpp SYSTEM INTERFACE 9 | $ 10 | ) 11 | target_link_libraries(websocketpp INTERFACE asio) 12 | 13 | add_subdirectory(pybind11) 14 | 15 | find_package(Threads) 16 | add_library(concurrentqueue INTERFACE) 17 | target_include_directories(concurrentqueue SYSTEM INTERFACE 18 | $ 19 | ) 20 | target_link_libraries(concurrentqueue INTERFACE 21 | ${CMAKE_THREAD_LIBS_INIT}) 22 | 23 | add_library(json INTERFACE) 24 | target_include_directories(json SYSTEM INTERFACE 25 | $ 26 | ) 27 | 28 | add_library(microtar INTERFACE) 29 | target_sources(microtar INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/microtar.c) 30 | target_include_directories(microtar SYSTEM INTERFACE 31 | $ 32 | ) 33 | -------------------------------------------------------------------------------- /vendor/LICENSE-asio: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /vendor/LICENSE-json.MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2013-2017 Niels Lohmann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/asio/basic_streambuf_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // basic_streambuf_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_BASIC_STREAMBUF_FWD_HPP 12 | #define ASIO_BASIC_STREAMBUF_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_NO_IOSTREAM) 21 | 22 | #include 23 | 24 | namespace asio { 25 | 26 | template > 27 | class basic_streambuf; 28 | 29 | } // namespace asio 30 | 31 | #endif // !defined(ASIO_NO_IOSTREAM) 32 | 33 | #endif // ASIO_BASIC_STREAMBUF_FWD_HPP 34 | -------------------------------------------------------------------------------- /vendor/asio/buffered_read_stream_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // buffered_read_stream_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_BUFFERED_READ_STREAM_FWD_HPP 12 | #define ASIO_BUFFERED_READ_STREAM_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | namespace asio { 19 | 20 | template 21 | class buffered_read_stream; 22 | 23 | } // namespace asio 24 | 25 | #endif // ASIO_BUFFERED_READ_STREAM_FWD_HPP 26 | -------------------------------------------------------------------------------- /vendor/asio/buffered_stream_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // buffered_stream_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_BUFFERED_STREAM_FWD_HPP 12 | #define ASIO_BUFFERED_STREAM_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | namespace asio { 19 | 20 | template 21 | class buffered_stream; 22 | 23 | } // namespace asio 24 | 25 | #endif // ASIO_BUFFERED_STREAM_FWD_HPP 26 | -------------------------------------------------------------------------------- /vendor/asio/buffered_write_stream_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // buffered_write_stream_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_BUFFERED_WRITE_STREAM_FWD_HPP 12 | #define ASIO_BUFFERED_WRITE_STREAM_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | namespace asio { 19 | 20 | template 21 | class buffered_write_stream; 22 | 23 | } // namespace asio 24 | 25 | #endif // ASIO_BUFFERED_WRITE_STREAM_FWD_HPP 26 | -------------------------------------------------------------------------------- /vendor/asio/deadline_timer.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // deadline_timer.hpp 3 | // ~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DEADLINE_TIMER_HPP 12 | #define ASIO_DEADLINE_TIMER_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_BOOST_DATE_TIME) \ 21 | || defined(GENERATING_DOCUMENTATION) 22 | 23 | #include "asio/detail/socket_types.hpp" // Must come before posix_time. 24 | #include "asio/basic_deadline_timer.hpp" 25 | 26 | #include 27 | 28 | namespace asio { 29 | 30 | /// Typedef for the typical usage of timer. Uses a UTC clock. 31 | typedef basic_deadline_timer deadline_timer; 32 | 33 | } // namespace asio 34 | 35 | #endif // defined(ASIO_HAS_BOOST_DATE_TIME) 36 | // || defined(GENERATING_DOCUMENTATION) 37 | 38 | #endif // ASIO_DEADLINE_TIMER_HPP 39 | -------------------------------------------------------------------------------- /vendor/asio/detail/addressof.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/addressof.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_ADDRESSOF_HPP 12 | #define ASIO_DETAIL_ADDRESSOF_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_STD_ADDRESSOF) 21 | # include 22 | #else // defined(ASIO_HAS_STD_ADDRESSOF) 23 | # include 24 | #endif // defined(ASIO_HAS_STD_ADDRESSOF) 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | #if defined(ASIO_HAS_STD_ADDRESSOF) 30 | using std::addressof; 31 | #else // defined(ASIO_HAS_STD_ADDRESSOF) 32 | using boost::addressof; 33 | #endif // defined(ASIO_HAS_STD_ADDRESSOF) 34 | 35 | } // namespace detail 36 | } // namespace asio 37 | 38 | #endif // ASIO_DETAIL_ADDRESSOF_HPP 39 | -------------------------------------------------------------------------------- /vendor/asio/detail/array.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/array.hpp 3 | // ~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_ARRAY_HPP 12 | #define ASIO_DETAIL_ARRAY_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_STD_ARRAY) 21 | # include 22 | #else // defined(ASIO_HAS_STD_ARRAY) 23 | # include 24 | #endif // defined(ASIO_HAS_STD_ARRAY) 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | #if defined(ASIO_HAS_STD_ARRAY) 30 | using std::array; 31 | #else // defined(ASIO_HAS_STD_ARRAY) 32 | using boost::array; 33 | #endif // defined(ASIO_HAS_STD_ARRAY) 34 | 35 | } // namespace detail 36 | } // namespace asio 37 | 38 | #endif // ASIO_DETAIL_ARRAY_HPP 39 | -------------------------------------------------------------------------------- /vendor/asio/detail/array_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/array_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_ARRAY_FWD_HPP 12 | #define ASIO_DETAIL_ARRAY_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | namespace boost { 21 | 22 | template 23 | class array; 24 | 25 | } // namespace boost 26 | 27 | // Standard library components can't be forward declared, so we'll have to 28 | // include the array header. Fortunately, it's fairly lightweight and doesn't 29 | // add significantly to the compile time. 30 | #if defined(ASIO_HAS_STD_ARRAY) 31 | # include 32 | #endif // defined(ASIO_HAS_STD_ARRAY) 33 | 34 | #endif // ASIO_DETAIL_ARRAY_FWD_HPP 35 | -------------------------------------------------------------------------------- /vendor/asio/detail/assert.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/assert.hpp 3 | // ~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_ASSERT_HPP 12 | #define ASIO_DETAIL_ASSERT_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_BOOST_ASSERT) 21 | # include 22 | #else // defined(ASIO_HAS_BOOST_ASSERT) 23 | # include 24 | #endif // defined(ASIO_HAS_BOOST_ASSERT) 25 | 26 | #if defined(ASIO_HAS_BOOST_ASSERT) 27 | # define ASIO_ASSERT(expr) BOOST_ASSERT(expr) 28 | #else // defined(ASIO_HAS_BOOST_ASSERT) 29 | # define ASIO_ASSERT(expr) assert(expr) 30 | #endif // defined(ASIO_HAS_BOOST_ASSERT) 31 | 32 | #endif // ASIO_DETAIL_ASSERT_HPP 33 | -------------------------------------------------------------------------------- /vendor/asio/detail/atomic_count.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/atomic_count.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_ATOMIC_COUNT_HPP 12 | #define ASIO_DETAIL_ATOMIC_COUNT_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_HAS_THREADS) 21 | // Nothing to include. 22 | #elif defined(ASIO_HAS_STD_ATOMIC) 23 | # include 24 | #else // defined(ASIO_HAS_STD_ATOMIC) 25 | # include 26 | #endif // defined(ASIO_HAS_STD_ATOMIC) 27 | 28 | namespace asio { 29 | namespace detail { 30 | 31 | #if !defined(ASIO_HAS_THREADS) 32 | typedef long atomic_count; 33 | inline void increment(atomic_count& a, long b) { a += b; } 34 | #elif defined(ASIO_HAS_STD_ATOMIC) 35 | typedef std::atomic atomic_count; 36 | inline void increment(atomic_count& a, long b) { a += b; } 37 | #else // defined(ASIO_HAS_STD_ATOMIC) 38 | typedef boost::detail::atomic_count atomic_count; 39 | inline void increment(atomic_count& a, long b) { while (b > 0) ++a, --b; } 40 | #endif // defined(ASIO_HAS_STD_ATOMIC) 41 | 42 | } // namespace detail 43 | } // namespace asio 44 | 45 | #endif // ASIO_DETAIL_ATOMIC_COUNT_HPP 46 | -------------------------------------------------------------------------------- /vendor/asio/detail/cstdint.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/cstdint.hpp 3 | // ~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_CSTDINT_HPP 12 | #define ASIO_DETAIL_CSTDINT_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_CSTDINT) 21 | # include 22 | #else // defined(ASIO_HAS_CSTDINT) 23 | # include 24 | #endif // defined(ASIO_HAS_CSTDINT) 25 | 26 | namespace asio { 27 | 28 | #if defined(ASIO_HAS_CSTDINT) 29 | using std::int16_t; 30 | using std::uint16_t; 31 | using std::int32_t; 32 | using std::uint32_t; 33 | using std::int64_t; 34 | using std::uint64_t; 35 | #else // defined(ASIO_HAS_CSTDINT) 36 | using boost::int16_t; 37 | using boost::uint16_t; 38 | using boost::int32_t; 39 | using boost::uint32_t; 40 | using boost::int64_t; 41 | using boost::uint64_t; 42 | #endif // defined(ASIO_HAS_CSTDINT) 43 | 44 | } // namespace asio 45 | 46 | #endif // ASIO_DETAIL_CSTDINT_HPP 47 | -------------------------------------------------------------------------------- /vendor/asio/detail/date_time_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/date_time_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_DATE_TIME_FWD_HPP 12 | #define ASIO_DETAIL_DATE_TIME_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | namespace boost { 21 | namespace date_time { 22 | 23 | template 24 | class base_time; 25 | 26 | } // namespace date_time 27 | namespace posix_time { 28 | 29 | class ptime; 30 | 31 | } // namespace posix_time 32 | } // namespace boost 33 | 34 | #endif // ASIO_DETAIL_DATE_TIME_FWD_HPP 35 | -------------------------------------------------------------------------------- /vendor/asio/detail/dependent_type.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/dependent_type.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_DEPENDENT_TYPE_HPP 12 | #define ASIO_DETAIL_DEPENDENT_TYPE_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #include "asio/detail/push_options.hpp" 21 | 22 | namespace asio { 23 | namespace detail { 24 | 25 | template 26 | struct dependent_type 27 | { 28 | typedef T type; 29 | }; 30 | 31 | } // namespace detail 32 | } // namespace asio 33 | 34 | #include "asio/detail/pop_options.hpp" 35 | 36 | #endif // ASIO_DETAIL_DEPENDENT_TYPE_HPP 37 | -------------------------------------------------------------------------------- /vendor/asio/detail/event.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/event.hpp 3 | // ~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_EVENT_HPP 12 | #define ASIO_DETAIL_EVENT_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_HAS_THREADS) 21 | # include "asio/detail/null_event.hpp" 22 | #elif defined(ASIO_WINDOWS) 23 | # include "asio/detail/win_event.hpp" 24 | #elif defined(ASIO_HAS_PTHREADS) 25 | # include "asio/detail/posix_event.hpp" 26 | #elif defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR) 27 | # include "asio/detail/std_event.hpp" 28 | #else 29 | # error Only Windows, POSIX and std::condition_variable are supported! 30 | #endif 31 | 32 | namespace asio { 33 | namespace detail { 34 | 35 | #if !defined(ASIO_HAS_THREADS) 36 | typedef null_event event; 37 | #elif defined(ASIO_WINDOWS) 38 | typedef win_event event; 39 | #elif defined(ASIO_HAS_PTHREADS) 40 | typedef posix_event event; 41 | #elif defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR) 42 | typedef std_event event; 43 | #endif 44 | 45 | } // namespace detail 46 | } // namespace asio 47 | 48 | #endif // ASIO_DETAIL_EVENT_HPP 49 | -------------------------------------------------------------------------------- /vendor/asio/detail/fd_set_adapter.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/fd_set_adapter.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_FD_SET_ADAPTER_HPP 12 | #define ASIO_DETAIL_FD_SET_ADAPTER_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_WINDOWS_RUNTIME) 21 | 22 | #include "asio/detail/posix_fd_set_adapter.hpp" 23 | #include "asio/detail/win_fd_set_adapter.hpp" 24 | 25 | namespace asio { 26 | namespace detail { 27 | 28 | #if defined(ASIO_WINDOWS) || defined(__CYGWIN__) 29 | typedef win_fd_set_adapter fd_set_adapter; 30 | #else 31 | typedef posix_fd_set_adapter fd_set_adapter; 32 | #endif 33 | 34 | } // namespace detail 35 | } // namespace asio 36 | 37 | #endif // !defined(ASIO_WINDOWS_RUNTIME) 38 | 39 | #endif // ASIO_DETAIL_FD_SET_ADAPTER_HPP 40 | -------------------------------------------------------------------------------- /vendor/asio/detail/function.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/function.hpp 3 | // ~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_FUNCTION_HPP 12 | #define ASIO_DETAIL_FUNCTION_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_STD_FUNCTION) 21 | # include 22 | #else // defined(ASIO_HAS_STD_FUNCTION) 23 | # include 24 | #endif // defined(ASIO_HAS_STD_FUNCTION) 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | #if defined(ASIO_HAS_STD_FUNCTION) 30 | using std::function; 31 | #else // defined(ASIO_HAS_STD_FUNCTION) 32 | using boost::function; 33 | #endif // defined(ASIO_HAS_STD_FUNCTION) 34 | 35 | } // namespace detail 36 | } // namespace asio 37 | 38 | #endif // ASIO_DETAIL_FUNCTION_HPP 39 | -------------------------------------------------------------------------------- /vendor/asio/detail/handler_cont_helpers.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/handler_cont_helpers.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_HANDLER_CONT_HELPERS_HPP 12 | #define ASIO_DETAIL_HANDLER_CONT_HELPERS_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include "asio/detail/addressof.hpp" 20 | #include "asio/handler_continuation_hook.hpp" 21 | 22 | #include "asio/detail/push_options.hpp" 23 | 24 | // Calls to asio_handler_is_continuation must be made from a namespace that 25 | // does not contain overloads of this function. This namespace is defined here 26 | // for that purpose. 27 | namespace asio_handler_cont_helpers { 28 | 29 | template 30 | inline bool is_continuation(Context& context) 31 | { 32 | #if !defined(ASIO_HAS_HANDLER_HOOKS) 33 | return false; 34 | #else 35 | using asio::asio_handler_is_continuation; 36 | return asio_handler_is_continuation( 37 | asio::detail::addressof(context)); 38 | #endif 39 | } 40 | 41 | } // namespace asio_handler_cont_helpers 42 | 43 | #include "asio/detail/pop_options.hpp" 44 | 45 | #endif // ASIO_DETAIL_HANDLER_CONT_HELPERS_HPP 46 | -------------------------------------------------------------------------------- /vendor/asio/detail/impl/posix_event.ipp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/impl/posix_event.ipp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_IMPL_POSIX_EVENT_IPP 12 | #define ASIO_DETAIL_IMPL_POSIX_EVENT_IPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_PTHREADS) 21 | 22 | #include "asio/detail/posix_event.hpp" 23 | #include "asio/detail/throw_error.hpp" 24 | #include "asio/error.hpp" 25 | 26 | #include "asio/detail/push_options.hpp" 27 | 28 | namespace asio { 29 | namespace detail { 30 | 31 | posix_event::posix_event() 32 | : state_(0) 33 | { 34 | int error = ::pthread_cond_init(&cond_, 0); 35 | asio::error_code ec(error, 36 | asio::error::get_system_category()); 37 | asio::detail::throw_error(ec, "event"); 38 | } 39 | 40 | } // namespace detail 41 | } // namespace asio 42 | 43 | #include "asio/detail/pop_options.hpp" 44 | 45 | #endif // defined(ASIO_HAS_PTHREADS) 46 | 47 | #endif // ASIO_DETAIL_IMPL_POSIX_EVENT_IPP 48 | -------------------------------------------------------------------------------- /vendor/asio/detail/impl/posix_mutex.ipp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/impl/posix_mutex.ipp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_IMPL_POSIX_MUTEX_IPP 12 | #define ASIO_DETAIL_IMPL_POSIX_MUTEX_IPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_PTHREADS) 21 | 22 | #include "asio/detail/posix_mutex.hpp" 23 | #include "asio/detail/throw_error.hpp" 24 | #include "asio/error.hpp" 25 | 26 | #include "asio/detail/push_options.hpp" 27 | 28 | namespace asio { 29 | namespace detail { 30 | 31 | posix_mutex::posix_mutex() 32 | { 33 | int error = ::pthread_mutex_init(&mutex_, 0); 34 | asio::error_code ec(error, 35 | asio::error::get_system_category()); 36 | asio::detail::throw_error(ec, "mutex"); 37 | } 38 | 39 | } // namespace detail 40 | } // namespace asio 41 | 42 | #include "asio/detail/pop_options.hpp" 43 | 44 | #endif // defined(ASIO_HAS_PTHREADS) 45 | 46 | #endif // ASIO_DETAIL_IMPL_POSIX_MUTEX_IPP 47 | -------------------------------------------------------------------------------- /vendor/asio/detail/impl/posix_tss_ptr.ipp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/impl/posix_tss_ptr.ipp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_IMPL_POSIX_TSS_PTR_IPP 12 | #define ASIO_DETAIL_IMPL_POSIX_TSS_PTR_IPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_PTHREADS) 21 | 22 | #include "asio/detail/posix_tss_ptr.hpp" 23 | #include "asio/detail/throw_error.hpp" 24 | #include "asio/error.hpp" 25 | 26 | #include "asio/detail/push_options.hpp" 27 | 28 | namespace asio { 29 | namespace detail { 30 | 31 | void posix_tss_ptr_create(pthread_key_t& key) 32 | { 33 | int error = ::pthread_key_create(&key, 0); 34 | asio::error_code ec(error, 35 | asio::error::get_system_category()); 36 | asio::detail::throw_error(ec, "tss"); 37 | } 38 | 39 | } // namespace detail 40 | } // namespace asio 41 | 42 | #include "asio/detail/pop_options.hpp" 43 | 44 | #endif // defined(ASIO_HAS_PTHREADS) 45 | 46 | #endif // ASIO_DETAIL_IMPL_POSIX_TSS_PTR_IPP 47 | -------------------------------------------------------------------------------- /vendor/asio/detail/impl/win_tss_ptr.ipp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/impl/win_tss_ptr.ipp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_IMPL_WIN_TSS_PTR_IPP 12 | #define ASIO_DETAIL_IMPL_WIN_TSS_PTR_IPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_WINDOWS) 21 | 22 | #include "asio/detail/throw_error.hpp" 23 | #include "asio/detail/win_tss_ptr.hpp" 24 | #include "asio/error.hpp" 25 | 26 | #include "asio/detail/push_options.hpp" 27 | 28 | namespace asio { 29 | namespace detail { 30 | 31 | DWORD win_tss_ptr_create() 32 | { 33 | #if defined(UNDER_CE) 34 | enum { out_of_indexes = 0xFFFFFFFF }; 35 | #else 36 | enum { out_of_indexes = TLS_OUT_OF_INDEXES }; 37 | #endif 38 | 39 | DWORD tss_key = ::TlsAlloc(); 40 | if (tss_key == out_of_indexes) 41 | { 42 | DWORD last_error = ::GetLastError(); 43 | asio::error_code ec(last_error, 44 | asio::error::get_system_category()); 45 | asio::detail::throw_error(ec, "tss"); 46 | } 47 | return tss_key; 48 | } 49 | 50 | } // namespace detail 51 | } // namespace asio 52 | 53 | #include "asio/detail/pop_options.hpp" 54 | 55 | #endif // defined(ASIO_WINDOWS) 56 | 57 | #endif // ASIO_DETAIL_IMPL_WIN_TSS_PTR_IPP 58 | -------------------------------------------------------------------------------- /vendor/asio/detail/keyword_tss_ptr.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/keyword_tss_ptr.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_KEYWORD_TSS_PTR_HPP 12 | #define ASIO_DETAIL_KEYWORD_TSS_PTR_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_THREAD_KEYWORD_EXTENSION) 21 | 22 | #include "asio/detail/noncopyable.hpp" 23 | 24 | #include "asio/detail/push_options.hpp" 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | template 30 | class keyword_tss_ptr 31 | : private noncopyable 32 | { 33 | public: 34 | // Constructor. 35 | keyword_tss_ptr() 36 | { 37 | } 38 | 39 | // Destructor. 40 | ~keyword_tss_ptr() 41 | { 42 | } 43 | 44 | // Get the value. 45 | operator T*() const 46 | { 47 | return value_; 48 | } 49 | 50 | // Set the value. 51 | void operator=(T* value) 52 | { 53 | value_ = value; 54 | } 55 | 56 | private: 57 | static ASIO_THREAD_KEYWORD T* value_; 58 | }; 59 | 60 | template 61 | ASIO_THREAD_KEYWORD T* keyword_tss_ptr::value_; 62 | 63 | } // namespace detail 64 | } // namespace asio 65 | 66 | #include "asio/detail/pop_options.hpp" 67 | 68 | #endif // defined(ASIO_HAS_THREAD_KEYWORD_EXTENSION) 69 | 70 | #endif // ASIO_DETAIL_KEYWORD_TSS_PTR_HPP 71 | -------------------------------------------------------------------------------- /vendor/asio/detail/limits.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/limits.hpp 3 | // ~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_LIMITS_HPP 12 | #define ASIO_DETAIL_LIMITS_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_BOOST_LIMITS) 21 | # include 22 | #else // defined(ASIO_HAS_BOOST_LIMITS) 23 | # include 24 | #endif // defined(ASIO_HAS_BOOST_LIMITS) 25 | 26 | #endif // ASIO_DETAIL_LIMITS_HPP 27 | -------------------------------------------------------------------------------- /vendor/asio/detail/local_free_on_block_exit.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/local_free_on_block_exit.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_LOCAL_FREE_ON_BLOCK_EXIT_HPP 12 | #define ASIO_DETAIL_LOCAL_FREE_ON_BLOCK_EXIT_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_WINDOWS) || defined(__CYGWIN__) 21 | #if !defined(ASIO_WINDOWS_APP) 22 | 23 | #include "asio/detail/noncopyable.hpp" 24 | #include "asio/detail/socket_types.hpp" 25 | 26 | #include "asio/detail/push_options.hpp" 27 | 28 | namespace asio { 29 | namespace detail { 30 | 31 | class local_free_on_block_exit 32 | : private noncopyable 33 | { 34 | public: 35 | // Constructor blocks all signals for the calling thread. 36 | explicit local_free_on_block_exit(void* p) 37 | : p_(p) 38 | { 39 | } 40 | 41 | // Destructor restores the previous signal mask. 42 | ~local_free_on_block_exit() 43 | { 44 | ::LocalFree(p_); 45 | } 46 | 47 | private: 48 | void* p_; 49 | }; 50 | 51 | } // namespace detail 52 | } // namespace asio 53 | 54 | #include "asio/detail/pop_options.hpp" 55 | 56 | #endif // !defined(ASIO_WINDOWS_APP) 57 | #endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__) 58 | 59 | #endif // ASIO_DETAIL_LOCAL_FREE_ON_BLOCK_EXIT_HPP 60 | -------------------------------------------------------------------------------- /vendor/asio/detail/macos_fenced_block.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/macos_fenced_block.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_MACOS_FENCED_BLOCK_HPP 12 | #define ASIO_DETAIL_MACOS_FENCED_BLOCK_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(__MACH__) && defined(__APPLE__) 21 | 22 | #include 23 | 24 | #include "asio/detail/push_options.hpp" 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | class macos_fenced_block 30 | : private noncopyable 31 | { 32 | public: 33 | enum half_t { half }; 34 | enum full_t { full }; 35 | 36 | // Constructor for a half fenced block. 37 | explicit macos_fenced_block(half_t) 38 | { 39 | } 40 | 41 | // Constructor for a full fenced block. 42 | explicit macos_fenced_block(full_t) 43 | { 44 | OSMemoryBarrier(); 45 | } 46 | 47 | // Destructor. 48 | ~macos_fenced_block() 49 | { 50 | OSMemoryBarrier(); 51 | } 52 | }; 53 | 54 | } // namespace detail 55 | } // namespace asio 56 | 57 | #include "asio/detail/pop_options.hpp" 58 | 59 | #endif // defined(__MACH__) && defined(__APPLE__) 60 | 61 | #endif // ASIO_DETAIL_MACOS_FENCED_BLOCK_HPP 62 | -------------------------------------------------------------------------------- /vendor/asio/detail/mutex.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/mutex.hpp 3 | // ~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_MUTEX_HPP 12 | #define ASIO_DETAIL_MUTEX_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_HAS_THREADS) 21 | # include "asio/detail/null_mutex.hpp" 22 | #elif defined(ASIO_WINDOWS) 23 | # include "asio/detail/win_mutex.hpp" 24 | #elif defined(ASIO_HAS_PTHREADS) 25 | # include "asio/detail/posix_mutex.hpp" 26 | #elif defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR) 27 | # include "asio/detail/std_mutex.hpp" 28 | #else 29 | # error Only Windows, POSIX and std::mutex are supported! 30 | #endif 31 | 32 | namespace asio { 33 | namespace detail { 34 | 35 | #if !defined(ASIO_HAS_THREADS) 36 | typedef null_mutex mutex; 37 | #elif defined(ASIO_WINDOWS) 38 | typedef win_mutex mutex; 39 | #elif defined(ASIO_HAS_PTHREADS) 40 | typedef posix_mutex mutex; 41 | #elif defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR) 42 | typedef std_mutex mutex; 43 | #endif 44 | 45 | } // namespace detail 46 | } // namespace asio 47 | 48 | #endif // ASIO_DETAIL_MUTEX_HPP 49 | -------------------------------------------------------------------------------- /vendor/asio/detail/noncopyable.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/noncopyable.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_NONCOPYABLE_HPP 12 | #define ASIO_DETAIL_NONCOPYABLE_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #include "asio/detail/push_options.hpp" 21 | 22 | namespace asio { 23 | namespace detail { 24 | 25 | class noncopyable 26 | { 27 | protected: 28 | noncopyable() {} 29 | ~noncopyable() {} 30 | private: 31 | noncopyable(const noncopyable&); 32 | const noncopyable& operator=(const noncopyable&); 33 | }; 34 | 35 | } // namespace detail 36 | 37 | using asio::detail::noncopyable; 38 | 39 | } // namespace asio 40 | 41 | #include "asio/detail/pop_options.hpp" 42 | 43 | #endif // ASIO_DETAIL_NONCOPYABLE_HPP 44 | -------------------------------------------------------------------------------- /vendor/asio/detail/null_fenced_block.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/null_fenced_block.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_NULL_FENCED_BLOCK_HPP 12 | #define ASIO_DETAIL_NULL_FENCED_BLOCK_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/push_options.hpp" 19 | 20 | namespace asio { 21 | namespace detail { 22 | 23 | class null_fenced_block 24 | : private noncopyable 25 | { 26 | public: 27 | enum half_or_full_t { half, full }; 28 | 29 | // Constructor. 30 | explicit null_fenced_block(half_or_full_t) 31 | { 32 | } 33 | 34 | // Destructor. 35 | ~null_fenced_block() 36 | { 37 | } 38 | }; 39 | 40 | } // namespace detail 41 | } // namespace asio 42 | 43 | #include "asio/detail/pop_options.hpp" 44 | 45 | #endif // ASIO_DETAIL_NULL_FENCED_BLOCK_HPP 46 | -------------------------------------------------------------------------------- /vendor/asio/detail/null_mutex.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/null_mutex.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_NULL_MUTEX_HPP 12 | #define ASIO_DETAIL_NULL_MUTEX_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_HAS_THREADS) 21 | 22 | #include "asio/detail/noncopyable.hpp" 23 | #include "asio/detail/scoped_lock.hpp" 24 | 25 | #include "asio/detail/push_options.hpp" 26 | 27 | namespace asio { 28 | namespace detail { 29 | 30 | class null_mutex 31 | : private noncopyable 32 | { 33 | public: 34 | typedef asio::detail::scoped_lock scoped_lock; 35 | 36 | // Constructor. 37 | null_mutex() 38 | { 39 | } 40 | 41 | // Destructor. 42 | ~null_mutex() 43 | { 44 | } 45 | 46 | // Lock the mutex. 47 | void lock() 48 | { 49 | } 50 | 51 | // Unlock the mutex. 52 | void unlock() 53 | { 54 | } 55 | }; 56 | 57 | } // namespace detail 58 | } // namespace asio 59 | 60 | #include "asio/detail/pop_options.hpp" 61 | 62 | #endif // !defined(ASIO_HAS_THREADS) 63 | 64 | #endif // ASIO_DETAIL_NULL_MUTEX_HPP 65 | -------------------------------------------------------------------------------- /vendor/asio/detail/null_reactor.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/null_reactor.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_NULL_REACTOR_HPP 12 | #define ASIO_DETAIL_NULL_REACTOR_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_WINDOWS_RUNTIME) 21 | 22 | #include "asio/io_service.hpp" 23 | 24 | #include "asio/detail/push_options.hpp" 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | class null_reactor 30 | : public asio::detail::service_base 31 | { 32 | public: 33 | // Constructor. 34 | null_reactor(asio::io_service& io_service) 35 | : asio::detail::service_base(io_service) 36 | { 37 | } 38 | 39 | // Destructor. 40 | ~null_reactor() 41 | { 42 | } 43 | 44 | // Destroy all user-defined handler objects owned by the service. 45 | void shutdown_service() 46 | { 47 | } 48 | 49 | // No-op because should never be called. 50 | void run(bool /*block*/, op_queue& /*ops*/) 51 | { 52 | } 53 | 54 | // No-op. 55 | void interrupt() 56 | { 57 | } 58 | }; 59 | 60 | } // namespace detail 61 | } // namespace asio 62 | 63 | #include "asio/detail/pop_options.hpp" 64 | 65 | #endif // defined(ASIO_WINDOWS_RUNTIME) 66 | 67 | #endif // ASIO_DETAIL_NULL_REACTOR_HPP 68 | -------------------------------------------------------------------------------- /vendor/asio/detail/null_static_mutex.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/null_static_mutex.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_NULL_STATIC_MUTEX_HPP 12 | #define ASIO_DETAIL_NULL_STATIC_MUTEX_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_HAS_THREADS) 21 | 22 | #include "asio/detail/scoped_lock.hpp" 23 | 24 | #include "asio/detail/push_options.hpp" 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | struct null_static_mutex 30 | { 31 | typedef asio::detail::scoped_lock scoped_lock; 32 | 33 | // Initialise the mutex. 34 | void init() 35 | { 36 | } 37 | 38 | // Lock the mutex. 39 | void lock() 40 | { 41 | } 42 | 43 | // Unlock the mutex. 44 | void unlock() 45 | { 46 | } 47 | 48 | int unused_; 49 | }; 50 | 51 | #define ASIO_NULL_STATIC_MUTEX_INIT { 0 } 52 | 53 | } // namespace detail 54 | } // namespace asio 55 | 56 | #include "asio/detail/pop_options.hpp" 57 | 58 | #endif // !defined(ASIO_HAS_THREADS) 59 | 60 | #endif // ASIO_DETAIL_NULL_STATIC_MUTEX_HPP 61 | -------------------------------------------------------------------------------- /vendor/asio/detail/null_thread.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/null_thread.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_NULL_THREAD_HPP 12 | #define ASIO_DETAIL_NULL_THREAD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_HAS_THREADS) 21 | 22 | #include "asio/detail/noncopyable.hpp" 23 | #include "asio/detail/throw_error.hpp" 24 | #include "asio/error.hpp" 25 | 26 | #include "asio/detail/push_options.hpp" 27 | 28 | namespace asio { 29 | namespace detail { 30 | 31 | class null_thread 32 | : private noncopyable 33 | { 34 | public: 35 | // Constructor. 36 | template 37 | null_thread(Function, unsigned int = 0) 38 | { 39 | asio::detail::throw_error( 40 | asio::error::operation_not_supported, "thread"); 41 | } 42 | 43 | // Destructor. 44 | ~null_thread() 45 | { 46 | } 47 | 48 | // Wait for the thread to exit. 49 | void join() 50 | { 51 | } 52 | }; 53 | 54 | } // namespace detail 55 | } // namespace asio 56 | 57 | #include "asio/detail/pop_options.hpp" 58 | 59 | #endif // !defined(ASIO_HAS_THREADS) 60 | 61 | #endif // ASIO_DETAIL_NULL_THREAD_HPP 62 | -------------------------------------------------------------------------------- /vendor/asio/detail/null_tss_ptr.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/null_tss_ptr.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_NULL_TSS_PTR_HPP 12 | #define ASIO_DETAIL_NULL_TSS_PTR_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_HAS_THREADS) 21 | 22 | #include "asio/detail/noncopyable.hpp" 23 | 24 | #include "asio/detail/push_options.hpp" 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | template 30 | class null_tss_ptr 31 | : private noncopyable 32 | { 33 | public: 34 | // Constructor. 35 | null_tss_ptr() 36 | : value_(0) 37 | { 38 | } 39 | 40 | // Destructor. 41 | ~null_tss_ptr() 42 | { 43 | } 44 | 45 | // Get the value. 46 | operator T*() const 47 | { 48 | return value_; 49 | } 50 | 51 | // Set the value. 52 | void operator=(T* value) 53 | { 54 | value_ = value; 55 | } 56 | 57 | private: 58 | T* value_; 59 | }; 60 | 61 | } // namespace detail 62 | } // namespace asio 63 | 64 | #include "asio/detail/pop_options.hpp" 65 | 66 | #endif // !defined(ASIO_HAS_THREADS) 67 | 68 | #endif // ASIO_DETAIL_NULL_TSS_PTR_HPP 69 | -------------------------------------------------------------------------------- /vendor/asio/detail/operation.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/operation.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_OPERATION_HPP 12 | #define ASIO_DETAIL_OPERATION_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_IOCP) 21 | # include "asio/detail/win_iocp_operation.hpp" 22 | #else 23 | # include "asio/detail/task_io_service_operation.hpp" 24 | #endif 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | #if defined(ASIO_HAS_IOCP) 30 | typedef win_iocp_operation operation; 31 | #else 32 | typedef task_io_service_operation operation; 33 | #endif 34 | 35 | } // namespace detail 36 | } // namespace asio 37 | 38 | #endif // ASIO_DETAIL_OPERATION_HPP 39 | -------------------------------------------------------------------------------- /vendor/asio/detail/posix_static_mutex.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/posix_static_mutex.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_POSIX_STATIC_MUTEX_HPP 12 | #define ASIO_DETAIL_POSIX_STATIC_MUTEX_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_PTHREADS) 21 | 22 | #include 23 | #include "asio/detail/scoped_lock.hpp" 24 | 25 | #include "asio/detail/push_options.hpp" 26 | 27 | namespace asio { 28 | namespace detail { 29 | 30 | struct posix_static_mutex 31 | { 32 | typedef asio::detail::scoped_lock scoped_lock; 33 | 34 | // Initialise the mutex. 35 | void init() 36 | { 37 | // Nothing to do. 38 | } 39 | 40 | // Lock the mutex. 41 | void lock() 42 | { 43 | (void)::pthread_mutex_lock(&mutex_); // Ignore EINVAL. 44 | } 45 | 46 | // Unlock the mutex. 47 | void unlock() 48 | { 49 | (void)::pthread_mutex_unlock(&mutex_); // Ignore EINVAL. 50 | } 51 | 52 | ::pthread_mutex_t mutex_; 53 | }; 54 | 55 | #define ASIO_POSIX_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER } 56 | 57 | } // namespace detail 58 | } // namespace asio 59 | 60 | #include "asio/detail/pop_options.hpp" 61 | 62 | #endif // defined(ASIO_HAS_PTHREADS) 63 | 64 | #endif // ASIO_DETAIL_POSIX_STATIC_MUTEX_HPP 65 | -------------------------------------------------------------------------------- /vendor/asio/detail/reactor.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/reactor.hpp 3 | // ~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_REACTOR_HPP 12 | #define ASIO_DETAIL_REACTOR_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/reactor_fwd.hpp" 19 | 20 | #if defined(ASIO_HAS_EPOLL) 21 | # include "asio/detail/epoll_reactor.hpp" 22 | #elif defined(ASIO_HAS_KQUEUE) 23 | # include "asio/detail/kqueue_reactor.hpp" 24 | #elif defined(ASIO_HAS_DEV_POLL) 25 | # include "asio/detail/dev_poll_reactor.hpp" 26 | #elif defined(ASIO_WINDOWS_RUNTIME) 27 | # include "asio/detail/null_reactor.hpp" 28 | #else 29 | # include "asio/detail/select_reactor.hpp" 30 | #endif 31 | 32 | #endif // ASIO_DETAIL_REACTOR_HPP 33 | -------------------------------------------------------------------------------- /vendor/asio/detail/reactor_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/reactor_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_REACTOR_FWD_HPP 12 | #define ASIO_DETAIL_REACTOR_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | namespace asio { 21 | namespace detail { 22 | 23 | #if defined(ASIO_WINDOWS_RUNTIME) 24 | typedef class null_reactor reactor; 25 | #elif defined(ASIO_HAS_IOCP) 26 | typedef class select_reactor reactor; 27 | #elif defined(ASIO_HAS_EPOLL) 28 | typedef class epoll_reactor reactor; 29 | #elif defined(ASIO_HAS_KQUEUE) 30 | typedef class kqueue_reactor reactor; 31 | #elif defined(ASIO_HAS_DEV_POLL) 32 | typedef class dev_poll_reactor reactor; 33 | #else 34 | typedef class select_reactor reactor; 35 | #endif 36 | 37 | } // namespace detail 38 | } // namespace asio 39 | 40 | #endif // ASIO_DETAIL_REACTOR_FWD_HPP 41 | -------------------------------------------------------------------------------- /vendor/asio/detail/reactor_op.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/reactor_op.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_REACTOR_OP_HPP 12 | #define ASIO_DETAIL_REACTOR_OP_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include "asio/detail/operation.hpp" 20 | 21 | #include "asio/detail/push_options.hpp" 22 | 23 | namespace asio { 24 | namespace detail { 25 | 26 | class reactor_op 27 | : public operation 28 | { 29 | public: 30 | // The error code to be passed to the completion handler. 31 | asio::error_code ec_; 32 | 33 | // The number of bytes transferred, to be passed to the completion handler. 34 | std::size_t bytes_transferred_; 35 | 36 | // Perform the operation. Returns true if it is finished. 37 | bool perform() 38 | { 39 | return perform_func_(this); 40 | } 41 | 42 | protected: 43 | typedef bool (*perform_func_type)(reactor_op*); 44 | 45 | reactor_op(perform_func_type perform_func, func_type complete_func) 46 | : operation(complete_func), 47 | bytes_transferred_(0), 48 | perform_func_(perform_func) 49 | { 50 | } 51 | 52 | private: 53 | perform_func_type perform_func_; 54 | }; 55 | 56 | } // namespace detail 57 | } // namespace asio 58 | 59 | #include "asio/detail/pop_options.hpp" 60 | 61 | #endif // ASIO_DETAIL_REACTOR_OP_HPP 62 | -------------------------------------------------------------------------------- /vendor/asio/detail/regex_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/regex_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_REGEX_FWD_HPP 12 | #define ASIO_DETAIL_REGEX_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #if defined(ASIO_HAS_BOOST_REGEX) 19 | 20 | #include 21 | #include 22 | 23 | namespace boost { 24 | 25 | template 26 | struct sub_match; 27 | 28 | template 29 | class match_results; 30 | 31 | } // namespace boost 32 | 33 | #endif // defined(ASIO_HAS_BOOST_REGEX) 34 | 35 | #endif // ASIO_DETAIL_REGEX_FWD_HPP 36 | -------------------------------------------------------------------------------- /vendor/asio/detail/scoped_ptr.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/scoped_ptr.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_SCOPED_PTR_HPP 12 | #define ASIO_DETAIL_SCOPED_PTR_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #include "asio/detail/push_options.hpp" 21 | 22 | namespace asio { 23 | namespace detail { 24 | 25 | template 26 | class scoped_ptr 27 | { 28 | public: 29 | // Constructor. 30 | explicit scoped_ptr(T* p = 0) 31 | : p_(p) 32 | { 33 | } 34 | 35 | // Destructor. 36 | ~scoped_ptr() 37 | { 38 | delete p_; 39 | } 40 | 41 | // Access. 42 | T* get() 43 | { 44 | return p_; 45 | } 46 | 47 | // Access. 48 | T* operator->() 49 | { 50 | return p_; 51 | } 52 | 53 | // Dereference. 54 | T& operator*() 55 | { 56 | return *p_; 57 | } 58 | 59 | // Reset pointer. 60 | void reset(T* p = 0) 61 | { 62 | delete p_; 63 | p_ = p; 64 | } 65 | 66 | private: 67 | // Disallow copying and assignment. 68 | scoped_ptr(const scoped_ptr&); 69 | scoped_ptr& operator=(const scoped_ptr&); 70 | 71 | T* p_; 72 | }; 73 | 74 | } // namespace detail 75 | } // namespace asio 76 | 77 | #include "asio/detail/pop_options.hpp" 78 | 79 | #endif // ASIO_DETAIL_SCOPED_PTR_HPP 80 | -------------------------------------------------------------------------------- /vendor/asio/detail/select_interrupter.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/select_interrupter.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_SELECT_INTERRUPTER_HPP 12 | #define ASIO_DETAIL_SELECT_INTERRUPTER_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_WINDOWS_RUNTIME) 21 | 22 | #if defined(ASIO_WINDOWS) || defined(__CYGWIN__) || defined(__SYMBIAN32__) 23 | # include "asio/detail/socket_select_interrupter.hpp" 24 | #elif defined(ASIO_HAS_EVENTFD) 25 | # include "asio/detail/eventfd_select_interrupter.hpp" 26 | #else 27 | # include "asio/detail/pipe_select_interrupter.hpp" 28 | #endif 29 | 30 | namespace asio { 31 | namespace detail { 32 | 33 | #if defined(ASIO_WINDOWS) || defined(__CYGWIN__) || defined(__SYMBIAN32__) 34 | typedef socket_select_interrupter select_interrupter; 35 | #elif defined(ASIO_HAS_EVENTFD) 36 | typedef eventfd_select_interrupter select_interrupter; 37 | #else 38 | typedef pipe_select_interrupter select_interrupter; 39 | #endif 40 | 41 | } // namespace detail 42 | } // namespace asio 43 | 44 | #endif // !defined(ASIO_WINDOWS_RUNTIME) 45 | 46 | #endif // ASIO_DETAIL_SELECT_INTERRUPTER_HPP 47 | -------------------------------------------------------------------------------- /vendor/asio/detail/shared_ptr.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/shared_ptr.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_SHARED_PTR_HPP 12 | #define ASIO_DETAIL_SHARED_PTR_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_STD_SHARED_PTR) 21 | # include 22 | #else // defined(ASIO_HAS_STD_SHARED_PTR) 23 | # include 24 | #endif // defined(ASIO_HAS_STD_SHARED_PTR) 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | #if defined(ASIO_HAS_STD_SHARED_PTR) 30 | using std::shared_ptr; 31 | #else // defined(ASIO_HAS_STD_SHARED_PTR) 32 | using boost::shared_ptr; 33 | #endif // defined(ASIO_HAS_STD_SHARED_PTR) 34 | 35 | } // namespace detail 36 | } // namespace asio 37 | 38 | #endif // ASIO_DETAIL_SHARED_PTR_HPP 39 | -------------------------------------------------------------------------------- /vendor/asio/detail/signal_blocker.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/signal_blocker.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_SIGNAL_BLOCKER_HPP 12 | #define ASIO_DETAIL_SIGNAL_BLOCKER_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_HAS_THREADS) || defined(ASIO_WINDOWS) \ 21 | || defined(ASIO_WINDOWS_RUNTIME) \ 22 | || defined(__CYGWIN__) || defined(__SYMBIAN32__) 23 | # include "asio/detail/null_signal_blocker.hpp" 24 | #elif defined(ASIO_HAS_PTHREADS) 25 | # include "asio/detail/posix_signal_blocker.hpp" 26 | #else 27 | # error Only Windows and POSIX are supported! 28 | #endif 29 | 30 | namespace asio { 31 | namespace detail { 32 | 33 | #if !defined(ASIO_HAS_THREADS) || defined(ASIO_WINDOWS) \ 34 | || defined(ASIO_WINDOWS_RUNTIME) \ 35 | || defined(__CYGWIN__) || defined(__SYMBIAN32__) 36 | typedef null_signal_blocker signal_blocker; 37 | #elif defined(ASIO_HAS_PTHREADS) 38 | typedef posix_signal_blocker signal_blocker; 39 | #endif 40 | 41 | } // namespace detail 42 | } // namespace asio 43 | 44 | #endif // ASIO_DETAIL_SIGNAL_BLOCKER_HPP 45 | -------------------------------------------------------------------------------- /vendor/asio/detail/signal_init.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/signal_init.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_SIGNAL_INIT_HPP 12 | #define ASIO_DETAIL_SIGNAL_INIT_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_WINDOWS) && !defined(__CYGWIN__) 21 | 22 | #include 23 | 24 | #include "asio/detail/push_options.hpp" 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | template 30 | class signal_init 31 | { 32 | public: 33 | // Constructor. 34 | signal_init() 35 | { 36 | std::signal(Signal, SIG_IGN); 37 | } 38 | }; 39 | 40 | } // namespace detail 41 | } // namespace asio 42 | 43 | #include "asio/detail/pop_options.hpp" 44 | 45 | #endif // !defined(ASIO_WINDOWS) && !defined(__CYGWIN__) 46 | 47 | #endif // ASIO_DETAIL_SIGNAL_INIT_HPP 48 | -------------------------------------------------------------------------------- /vendor/asio/detail/signal_op.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/signal_op.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_SIGNAL_OP_HPP 12 | #define ASIO_DETAIL_SIGNAL_OP_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include "asio/detail/operation.hpp" 20 | 21 | #include "asio/detail/push_options.hpp" 22 | 23 | namespace asio { 24 | namespace detail { 25 | 26 | class signal_op 27 | : public operation 28 | { 29 | public: 30 | // The error code to be passed to the completion handler. 31 | asio::error_code ec_; 32 | 33 | // The signal number to be passed to the completion handler. 34 | int signal_number_; 35 | 36 | protected: 37 | signal_op(func_type func) 38 | : operation(func), 39 | signal_number_(0) 40 | { 41 | } 42 | }; 43 | 44 | } // namespace detail 45 | } // namespace asio 46 | 47 | #include "asio/detail/pop_options.hpp" 48 | 49 | #endif // ASIO_DETAIL_SIGNAL_OP_HPP 50 | -------------------------------------------------------------------------------- /vendor/asio/detail/solaris_fenced_block.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/solaris_fenced_block.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_SOLARIS_FENCED_BLOCK_HPP 12 | #define ASIO_DETAIL_SOLARIS_FENCED_BLOCK_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(__sun) 21 | 22 | #include 23 | 24 | #include "asio/detail/push_options.hpp" 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | class solaris_fenced_block 30 | : private noncopyable 31 | { 32 | public: 33 | enum half_t { half }; 34 | enum full_t { full }; 35 | 36 | // Constructor for a half fenced block. 37 | explicit solaris_fenced_block(half_t) 38 | { 39 | } 40 | 41 | // Constructor for a full fenced block. 42 | explicit solaris_fenced_block(full_t) 43 | { 44 | membar_consumer(); 45 | } 46 | 47 | // Destructor. 48 | ~solaris_fenced_block() 49 | { 50 | membar_producer(); 51 | } 52 | }; 53 | 54 | } // namespace detail 55 | } // namespace asio 56 | 57 | #include "asio/detail/pop_options.hpp" 58 | 59 | #endif // defined(__sun) 60 | 61 | #endif // ASIO_DETAIL_SOLARIS_FENCED_BLOCK_HPP 62 | -------------------------------------------------------------------------------- /vendor/asio/detail/std_mutex.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/std_mutex.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_STD_MUTEX_HPP 12 | #define ASIO_DETAIL_STD_MUTEX_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR) 21 | 22 | #include 23 | #include "asio/detail/noncopyable.hpp" 24 | #include "asio/detail/scoped_lock.hpp" 25 | 26 | #include "asio/detail/push_options.hpp" 27 | 28 | namespace asio { 29 | namespace detail { 30 | 31 | class std_event; 32 | 33 | class std_mutex 34 | : private noncopyable 35 | { 36 | public: 37 | typedef asio::detail::scoped_lock scoped_lock; 38 | 39 | // Constructor. 40 | std_mutex() 41 | { 42 | } 43 | 44 | // Destructor. 45 | ~std_mutex() 46 | { 47 | } 48 | 49 | // Lock the mutex. 50 | void lock() 51 | { 52 | mutex_.lock(); 53 | } 54 | 55 | // Unlock the mutex. 56 | void unlock() 57 | { 58 | mutex_.unlock(); 59 | } 60 | 61 | private: 62 | friend class std_event; 63 | std::mutex mutex_; 64 | }; 65 | 66 | } // namespace detail 67 | } // namespace asio 68 | 69 | #include "asio/detail/pop_options.hpp" 70 | 71 | #endif // defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR) 72 | 73 | #endif // ASIO_DETAIL_STD_MUTEX_HPP 74 | -------------------------------------------------------------------------------- /vendor/asio/detail/std_thread.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/std_thread.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_STD_THREAD_HPP 12 | #define ASIO_DETAIL_STD_THREAD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_STD_THREAD) 21 | 22 | #include 23 | #include "asio/detail/noncopyable.hpp" 24 | 25 | #include "asio/detail/push_options.hpp" 26 | 27 | namespace asio { 28 | namespace detail { 29 | 30 | class std_thread 31 | : private noncopyable 32 | { 33 | public: 34 | // Constructor. 35 | template 36 | std_thread(Function f, unsigned int = 0) 37 | : thread_(f) 38 | { 39 | } 40 | 41 | // Destructor. 42 | ~std_thread() 43 | { 44 | join(); 45 | } 46 | 47 | // Wait for the thread to exit. 48 | void join() 49 | { 50 | if (thread_.joinable()) 51 | thread_.join(); 52 | } 53 | 54 | private: 55 | std::thread thread_; 56 | }; 57 | 58 | } // namespace detail 59 | } // namespace asio 60 | 61 | #include "asio/detail/pop_options.hpp" 62 | 63 | #endif // defined(ASIO_HAS_STD_THREAD) 64 | 65 | #endif // ASIO_DETAIL_STD_THREAD_HPP 66 | -------------------------------------------------------------------------------- /vendor/asio/detail/task_io_service_thread_info.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/task_io_service_thread_info.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_TASK_IO_SERVICE_THREAD_INFO_HPP 12 | #define ASIO_DETAIL_TASK_IO_SERVICE_THREAD_INFO_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/op_queue.hpp" 19 | #include "asio/detail/thread_info_base.hpp" 20 | 21 | #include "asio/detail/push_options.hpp" 22 | 23 | namespace asio { 24 | namespace detail { 25 | 26 | class task_io_service; 27 | class task_io_service_operation; 28 | 29 | struct task_io_service_thread_info : public thread_info_base 30 | { 31 | op_queue private_op_queue; 32 | long private_outstanding_work; 33 | }; 34 | 35 | } // namespace detail 36 | } // namespace asio 37 | 38 | #include "asio/detail/pop_options.hpp" 39 | 40 | #endif // ASIO_DETAIL_TASK_IO_SERVICE_THREAD_INFO_HPP 41 | -------------------------------------------------------------------------------- /vendor/asio/detail/thread.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/thread.hpp 3 | // ~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_THREAD_HPP 12 | #define ASIO_DETAIL_THREAD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_HAS_THREADS) 21 | # include "asio/detail/null_thread.hpp" 22 | #elif defined(ASIO_WINDOWS) 23 | # if defined(ASIO_WINDOWS_APP) || defined(UNDER_CE) 24 | # include "asio/detail/winapi_thread.hpp" 25 | # else 26 | # include "asio/detail/win_thread.hpp" 27 | # endif 28 | #elif defined(ASIO_HAS_PTHREADS) 29 | # include "asio/detail/posix_thread.hpp" 30 | #elif defined(ASIO_HAS_STD_THREAD) 31 | # include "asio/detail/std_thread.hpp" 32 | #else 33 | # error Only Windows, POSIX and std::thread are supported! 34 | #endif 35 | 36 | namespace asio { 37 | namespace detail { 38 | 39 | #if !defined(ASIO_HAS_THREADS) 40 | typedef null_thread thread; 41 | #elif defined(ASIO_WINDOWS) 42 | # if defined(ASIO_WINDOWS_APP) || defined(UNDER_CE) 43 | typedef winapi_thread thread; 44 | # else 45 | typedef win_thread thread; 46 | # endif 47 | #elif defined(ASIO_HAS_PTHREADS) 48 | typedef posix_thread thread; 49 | #elif defined(ASIO_HAS_STD_THREAD) 50 | typedef std_thread thread; 51 | #endif 52 | 53 | } // namespace detail 54 | } // namespace asio 55 | 56 | #endif // ASIO_DETAIL_THREAD_HPP 57 | -------------------------------------------------------------------------------- /vendor/asio/detail/throw_error.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/throw_error.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_THROW_ERROR_HPP 12 | #define ASIO_DETAIL_THROW_ERROR_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include "asio/error_code.hpp" 20 | 21 | #include "asio/detail/push_options.hpp" 22 | 23 | namespace asio { 24 | namespace detail { 25 | 26 | ASIO_DECL void do_throw_error(const asio::error_code& err); 27 | 28 | ASIO_DECL void do_throw_error(const asio::error_code& err, 29 | const char* location); 30 | 31 | inline void throw_error(const asio::error_code& err) 32 | { 33 | if (err) 34 | do_throw_error(err); 35 | } 36 | 37 | inline void throw_error(const asio::error_code& err, 38 | const char* location) 39 | { 40 | if (err) 41 | do_throw_error(err, location); 42 | } 43 | 44 | } // namespace detail 45 | } // namespace asio 46 | 47 | #include "asio/detail/pop_options.hpp" 48 | 49 | #if defined(ASIO_HEADER_ONLY) 50 | # include "asio/detail/impl/throw_error.ipp" 51 | #endif // defined(ASIO_HEADER_ONLY) 52 | 53 | #endif // ASIO_DETAIL_THROW_ERROR_HPP 54 | -------------------------------------------------------------------------------- /vendor/asio/detail/throw_exception.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/throw_exception.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_THROW_EXCEPTION_HPP 12 | #define ASIO_DETAIL_THROW_EXCEPTION_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_BOOST_THROW_EXCEPTION) 21 | # include 22 | #endif // defined(ASIO_BOOST_THROW_EXCEPTION) 23 | 24 | namespace asio { 25 | namespace detail { 26 | 27 | #if defined(ASIO_HAS_BOOST_THROW_EXCEPTION) 28 | using boost::throw_exception; 29 | #else // defined(ASIO_HAS_BOOST_THROW_EXCEPTION) 30 | 31 | // Declare the throw_exception function for all targets. 32 | template 33 | void throw_exception(const Exception& e); 34 | 35 | // Only define the throw_exception function when exceptions are enabled. 36 | // Otherwise, it is up to the application to provide a definition of this 37 | // function. 38 | # if !defined(ASIO_NO_EXCEPTIONS) 39 | template 40 | void throw_exception(const Exception& e) 41 | { 42 | throw e; 43 | } 44 | # endif // !defined(ASIO_NO_EXCEPTIONS) 45 | 46 | #endif // defined(ASIO_HAS_BOOST_THROW_EXCEPTION) 47 | 48 | } // namespace detail 49 | } // namespace asio 50 | 51 | #endif // ASIO_DETAIL_THROW_EXCEPTION_HPP 52 | -------------------------------------------------------------------------------- /vendor/asio/detail/timer_scheduler.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/timer_scheduler.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_TIMER_SCHEDULER_HPP 12 | #define ASIO_DETAIL_TIMER_SCHEDULER_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include "asio/detail/timer_scheduler_fwd.hpp" 20 | 21 | #if defined(ASIO_WINDOWS_RUNTIME) 22 | # include "asio/detail/winrt_timer_scheduler.hpp" 23 | #elif defined(ASIO_HAS_IOCP) 24 | # include "asio/detail/win_iocp_io_service.hpp" 25 | #elif defined(ASIO_HAS_EPOLL) 26 | # include "asio/detail/epoll_reactor.hpp" 27 | #elif defined(ASIO_HAS_KQUEUE) 28 | # include "asio/detail/kqueue_reactor.hpp" 29 | #elif defined(ASIO_HAS_DEV_POLL) 30 | # include "asio/detail/dev_poll_reactor.hpp" 31 | #else 32 | # include "asio/detail/select_reactor.hpp" 33 | #endif 34 | 35 | #endif // ASIO_DETAIL_TIMER_SCHEDULER_HPP 36 | -------------------------------------------------------------------------------- /vendor/asio/detail/timer_scheduler_fwd.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/timer_scheduler_fwd.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_TIMER_SCHEDULER_FWD_HPP 12 | #define ASIO_DETAIL_TIMER_SCHEDULER_FWD_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | namespace asio { 21 | namespace detail { 22 | 23 | #if defined(ASIO_WINDOWS_RUNTIME) 24 | typedef class winrt_timer_scheduler timer_scheduler; 25 | #elif defined(ASIO_HAS_IOCP) 26 | typedef class win_iocp_io_service timer_scheduler; 27 | #elif defined(ASIO_HAS_EPOLL) 28 | typedef class epoll_reactor timer_scheduler; 29 | #elif defined(ASIO_HAS_KQUEUE) 30 | typedef class kqueue_reactor timer_scheduler; 31 | #elif defined(ASIO_HAS_DEV_POLL) 32 | typedef class dev_poll_reactor timer_scheduler; 33 | #else 34 | typedef class select_reactor timer_scheduler; 35 | #endif 36 | 37 | } // namespace detail 38 | } // namespace asio 39 | 40 | #endif // ASIO_DETAIL_TIMER_SCHEDULER_FWD_HPP 41 | -------------------------------------------------------------------------------- /vendor/asio/detail/wait_op.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/wait_op.hpp 3 | // ~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_WAIT_OP_HPP 12 | #define ASIO_DETAIL_WAIT_OP_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include "asio/detail/operation.hpp" 20 | 21 | #include "asio/detail/push_options.hpp" 22 | 23 | namespace asio { 24 | namespace detail { 25 | 26 | class wait_op 27 | : public operation 28 | { 29 | public: 30 | // The error code to be passed to the completion handler. 31 | asio::error_code ec_; 32 | 33 | protected: 34 | wait_op(func_type func) 35 | : operation(func) 36 | { 37 | } 38 | }; 39 | 40 | } // namespace detail 41 | } // namespace asio 42 | 43 | #include "asio/detail/pop_options.hpp" 44 | 45 | #endif // ASIO_DETAIL_WAIT_OP_HPP 46 | -------------------------------------------------------------------------------- /vendor/asio/detail/weak_ptr.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/weak_ptr.hpp 3 | // ~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_WEAK_PTR_HPP 12 | #define ASIO_DETAIL_WEAK_PTR_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_STD_SHARED_PTR) 21 | # include 22 | #else // defined(ASIO_HAS_STD_SHARED_PTR) 23 | # include 24 | #endif // defined(ASIO_HAS_STD_SHARED_PTR) 25 | 26 | namespace asio { 27 | namespace detail { 28 | 29 | #if defined(ASIO_HAS_STD_SHARED_PTR) 30 | using std::weak_ptr; 31 | #else // defined(ASIO_HAS_STD_SHARED_PTR) 32 | using boost::weak_ptr; 33 | #endif // defined(ASIO_HAS_STD_SHARED_PTR) 34 | 35 | } // namespace detail 36 | } // namespace asio 37 | 38 | #endif // ASIO_DETAIL_WEAK_PTR_HPP 39 | -------------------------------------------------------------------------------- /vendor/asio/detail/win_iocp_thread_info.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/win_iocp_thread_info.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_WIN_IOCP_THREAD_INFO_HPP 12 | #define ASIO_DETAIL_WIN_IOCP_THREAD_INFO_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/thread_info_base.hpp" 19 | 20 | #include "asio/detail/push_options.hpp" 21 | 22 | namespace asio { 23 | namespace detail { 24 | 25 | struct win_iocp_thread_info : public thread_info_base 26 | { 27 | }; 28 | 29 | } // namespace detail 30 | } // namespace asio 31 | 32 | #include "asio/detail/pop_options.hpp" 33 | 34 | #endif // ASIO_DETAIL_WIN_IOCP_THREAD_INFO_HPP 35 | -------------------------------------------------------------------------------- /vendor/asio/detail/winrt_async_op.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // detail/winrt_async_op.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_DETAIL_WINRT_ASYNC_OP_HPP 12 | #define ASIO_DETAIL_WINRT_ASYNC_OP_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include "asio/detail/operation.hpp" 20 | 21 | #include "asio/detail/push_options.hpp" 22 | 23 | namespace asio { 24 | namespace detail { 25 | 26 | template 27 | class winrt_async_op 28 | : public operation 29 | { 30 | public: 31 | // The error code to be passed to the completion handler. 32 | asio::error_code ec_; 33 | 34 | // The result of the operation, to be passed to the completion handler. 35 | TResult result_; 36 | 37 | protected: 38 | winrt_async_op(func_type complete_func) 39 | : operation(complete_func), 40 | result_() 41 | { 42 | } 43 | }; 44 | 45 | template <> 46 | class winrt_async_op 47 | : public operation 48 | { 49 | public: 50 | // The error code to be passed to the completion handler. 51 | asio::error_code ec_; 52 | 53 | protected: 54 | winrt_async_op(func_type complete_func) 55 | : operation(complete_func) 56 | { 57 | } 58 | }; 59 | 60 | } // namespace detail 61 | } // namespace asio 62 | 63 | #include "asio/detail/pop_options.hpp" 64 | 65 | #endif // ASIO_DETAIL_WINRT_ASYNC_OP_HPP 66 | -------------------------------------------------------------------------------- /vendor/asio/handler_continuation_hook.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // handler_continuation_hook.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_HANDLER_CONTINUATION_HOOK_HPP 12 | #define ASIO_HANDLER_CONTINUATION_HOOK_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #include "asio/detail/push_options.hpp" 21 | 22 | namespace asio { 23 | 24 | /// Default continuation function for handlers. 25 | /** 26 | * Asynchronous operations may represent a continuation of the asynchronous 27 | * control flow associated with the current handler. The implementation can use 28 | * this knowledge to optimise scheduling of the handler. 29 | * 30 | * Implement asio_handler_is_continuation for your own handlers to indicate 31 | * when a handler represents a continuation. 32 | * 33 | * The default implementation of the continuation hook returns false. 34 | * 35 | * @par Example 36 | * @code 37 | * class my_handler; 38 | * 39 | * bool asio_handler_is_continuation(my_handler* context) 40 | * { 41 | * return true; 42 | * } 43 | * @endcode 44 | */ 45 | inline bool asio_handler_is_continuation(...) 46 | { 47 | return false; 48 | } 49 | 50 | } // namespace asio 51 | 52 | #include "asio/detail/pop_options.hpp" 53 | 54 | #endif // ASIO_HANDLER_CONTINUATION_HOOK_HPP 55 | -------------------------------------------------------------------------------- /vendor/asio/impl/serial_port_base.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // impl/serial_port_base.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) 7 | // 8 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 9 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | 12 | #ifndef ASIO_IMPL_SERIAL_PORT_BASE_HPP 13 | #define ASIO_IMPL_SERIAL_PORT_BASE_HPP 14 | 15 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 | # pragma once 17 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 | 19 | #include "asio/detail/push_options.hpp" 20 | 21 | namespace asio { 22 | 23 | inline serial_port_base::baud_rate::baud_rate(unsigned int rate) 24 | : value_(rate) 25 | { 26 | } 27 | 28 | inline unsigned int serial_port_base::baud_rate::value() const 29 | { 30 | return value_; 31 | } 32 | 33 | inline serial_port_base::flow_control::type 34 | serial_port_base::flow_control::value() const 35 | { 36 | return value_; 37 | } 38 | 39 | inline serial_port_base::parity::type serial_port_base::parity::value() const 40 | { 41 | return value_; 42 | } 43 | 44 | inline serial_port_base::stop_bits::type 45 | serial_port_base::stop_bits::value() const 46 | { 47 | return value_; 48 | } 49 | 50 | inline unsigned int serial_port_base::character_size::value() const 51 | { 52 | return value_; 53 | } 54 | 55 | } // namespace asio 56 | 57 | #include "asio/detail/pop_options.hpp" 58 | 59 | #endif // ASIO_IMPL_SERIAL_PORT_BASE_HPP 60 | -------------------------------------------------------------------------------- /vendor/asio/impl/src.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // impl/src.cpp 3 | // ~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #if defined(_MSC_VER) \ 12 | || defined(__BORLANDC__) \ 13 | || defined(__DMC__) 14 | # pragma message ( \ 15 | "This file is deprecated. " \ 16 | "Please #include instead.") 17 | #elif defined(__GNUC__) \ 18 | || defined(__HP_aCC) \ 19 | || defined(__SUNPRO_CC) \ 20 | || defined(__IBMCPP__) 21 | # warning "This file is deprecated." 22 | # warning "Please #include instead." 23 | #endif 24 | 25 | #include "asio/impl/src.hpp" 26 | -------------------------------------------------------------------------------- /vendor/asio/ip/host_name.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ip/host_name.hpp 3 | // ~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_IP_HOST_NAME_HPP 12 | #define ASIO_IP_HOST_NAME_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include 20 | #include "asio/error_code.hpp" 21 | 22 | #include "asio/detail/push_options.hpp" 23 | 24 | namespace asio { 25 | namespace ip { 26 | 27 | /// Get the current host name. 28 | ASIO_DECL std::string host_name(); 29 | 30 | /// Get the current host name. 31 | ASIO_DECL std::string host_name(asio::error_code& ec); 32 | 33 | } // namespace ip 34 | } // namespace asio 35 | 36 | #include "asio/detail/pop_options.hpp" 37 | 38 | #if defined(ASIO_HEADER_ONLY) 39 | # include "asio/ip/impl/host_name.ipp" 40 | #endif // defined(ASIO_HEADER_ONLY) 41 | 42 | #endif // ASIO_IP_HOST_NAME_HPP 43 | -------------------------------------------------------------------------------- /vendor/asio/ip/impl/address.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ip/impl/address.hpp 3 | // ~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_IP_IMPL_ADDRESS_HPP 12 | #define ASIO_IP_IMPL_ADDRESS_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #if !defined(ASIO_NO_IOSTREAM) 19 | 20 | #include "asio/detail/throw_error.hpp" 21 | 22 | #include "asio/detail/push_options.hpp" 23 | 24 | namespace asio { 25 | namespace ip { 26 | 27 | template 28 | std::basic_ostream& operator<<( 29 | std::basic_ostream& os, const address& addr) 30 | { 31 | asio::error_code ec; 32 | std::string s = addr.to_string(ec); 33 | if (ec) 34 | { 35 | if (os.exceptions() & std::basic_ostream::failbit) 36 | asio::detail::throw_error(ec); 37 | else 38 | os.setstate(std::basic_ostream::failbit); 39 | } 40 | else 41 | for (std::string::iterator i = s.begin(); i != s.end(); ++i) 42 | os << os.widen(*i); 43 | return os; 44 | } 45 | 46 | } // namespace ip 47 | } // namespace asio 48 | 49 | #include "asio/detail/pop_options.hpp" 50 | 51 | #endif // !defined(ASIO_NO_IOSTREAM) 52 | 53 | #endif // ASIO_IP_IMPL_ADDRESS_HPP 54 | -------------------------------------------------------------------------------- /vendor/asio/ip/impl/address_v4.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ip/impl/address_v4.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_IP_IMPL_ADDRESS_V4_HPP 12 | #define ASIO_IP_IMPL_ADDRESS_V4_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #if !defined(ASIO_NO_IOSTREAM) 19 | 20 | #include "asio/detail/throw_error.hpp" 21 | 22 | #include "asio/detail/push_options.hpp" 23 | 24 | namespace asio { 25 | namespace ip { 26 | 27 | template 28 | std::basic_ostream& operator<<( 29 | std::basic_ostream& os, const address_v4& addr) 30 | { 31 | asio::error_code ec; 32 | std::string s = addr.to_string(ec); 33 | if (ec) 34 | { 35 | if (os.exceptions() & std::basic_ostream::failbit) 36 | asio::detail::throw_error(ec); 37 | else 38 | os.setstate(std::basic_ostream::failbit); 39 | } 40 | else 41 | for (std::string::iterator i = s.begin(); i != s.end(); ++i) 42 | os << os.widen(*i); 43 | return os; 44 | } 45 | 46 | } // namespace ip 47 | } // namespace asio 48 | 49 | #include "asio/detail/pop_options.hpp" 50 | 51 | #endif // !defined(ASIO_NO_IOSTREAM) 52 | 53 | #endif // ASIO_IP_IMPL_ADDRESS_V4_HPP 54 | -------------------------------------------------------------------------------- /vendor/asio/ip/impl/address_v6.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ip/impl/address_v6.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_IP_IMPL_ADDRESS_V6_HPP 12 | #define ASIO_IP_IMPL_ADDRESS_V6_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #if !defined(ASIO_NO_IOSTREAM) 19 | 20 | #include "asio/detail/throw_error.hpp" 21 | 22 | #include "asio/detail/push_options.hpp" 23 | 24 | namespace asio { 25 | namespace ip { 26 | 27 | template 28 | std::basic_ostream& operator<<( 29 | std::basic_ostream& os, const address_v6& addr) 30 | { 31 | asio::error_code ec; 32 | std::string s = addr.to_string(ec); 33 | if (ec) 34 | { 35 | if (os.exceptions() & std::basic_ostream::failbit) 36 | asio::detail::throw_error(ec); 37 | else 38 | os.setstate(std::basic_ostream::failbit); 39 | } 40 | else 41 | for (std::string::iterator i = s.begin(); i != s.end(); ++i) 42 | os << os.widen(*i); 43 | return os; 44 | } 45 | 46 | } // namespace ip 47 | } // namespace asio 48 | 49 | #include "asio/detail/pop_options.hpp" 50 | 51 | #endif // !defined(ASIO_NO_IOSTREAM) 52 | 53 | #endif // ASIO_IP_IMPL_ADDRESS_V6_HPP 54 | -------------------------------------------------------------------------------- /vendor/asio/ip/impl/host_name.ipp: -------------------------------------------------------------------------------- 1 | // 2 | // ip/impl/host_name.ipp 3 | // ~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_IP_IMPL_HOST_NAME_IPP 12 | #define ASIO_IP_IMPL_HOST_NAME_IPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include "asio/detail/socket_ops.hpp" 20 | #include "asio/detail/throw_error.hpp" 21 | #include "asio/detail/winsock_init.hpp" 22 | #include "asio/ip/host_name.hpp" 23 | 24 | #include "asio/detail/push_options.hpp" 25 | 26 | namespace asio { 27 | namespace ip { 28 | 29 | std::string host_name() 30 | { 31 | char name[1024]; 32 | asio::error_code ec; 33 | if (asio::detail::socket_ops::gethostname(name, sizeof(name), ec) != 0) 34 | { 35 | asio::detail::throw_error(ec); 36 | return std::string(); 37 | } 38 | return std::string(name); 39 | } 40 | 41 | std::string host_name(asio::error_code& ec) 42 | { 43 | char name[1024]; 44 | if (asio::detail::socket_ops::gethostname(name, sizeof(name), ec) != 0) 45 | return std::string(); 46 | return std::string(name); 47 | } 48 | 49 | } // namespace ip 50 | } // namespace asio 51 | 52 | #include "asio/detail/pop_options.hpp" 53 | 54 | #endif // ASIO_IP_IMPL_HOST_NAME_IPP 55 | -------------------------------------------------------------------------------- /vendor/asio/posix/stream_descriptor.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // posix/stream_descriptor.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_POSIX_STREAM_DESCRIPTOR_HPP 12 | #define ASIO_POSIX_STREAM_DESCRIPTOR_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) \ 21 | || defined(GENERATING_DOCUMENTATION) 22 | 23 | #include "asio/posix/basic_stream_descriptor.hpp" 24 | 25 | namespace asio { 26 | namespace posix { 27 | 28 | /// Typedef for the typical usage of a stream-oriented descriptor. 29 | typedef basic_stream_descriptor<> stream_descriptor; 30 | 31 | } // namespace posix 32 | } // namespace asio 33 | 34 | #endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) 35 | // || defined(GENERATING_DOCUMENTATION) 36 | 37 | #endif // ASIO_POSIX_STREAM_DESCRIPTOR_HPP 38 | -------------------------------------------------------------------------------- /vendor/asio/serial_port.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // serial_port.hpp 3 | // ~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) 7 | // 8 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 9 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | 12 | #ifndef ASIO_SERIAL_PORT_HPP 13 | #define ASIO_SERIAL_PORT_HPP 14 | 15 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 | # pragma once 17 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 | 19 | #include "asio/detail/config.hpp" 20 | 21 | #if defined(ASIO_HAS_SERIAL_PORT) \ 22 | || defined(GENERATING_DOCUMENTATION) 23 | 24 | #include "asio/basic_serial_port.hpp" 25 | 26 | namespace asio { 27 | 28 | /// Typedef for the typical usage of a serial port. 29 | typedef basic_serial_port<> serial_port; 30 | 31 | } // namespace asio 32 | 33 | #endif // defined(ASIO_HAS_SERIAL_PORT) 34 | // || defined(GENERATING_DOCUMENTATION) 35 | 36 | #endif // ASIO_SERIAL_PORT_HPP 37 | -------------------------------------------------------------------------------- /vendor/asio/signal_set.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // signal_set.hpp 3 | // ~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_SIGNAL_SET_HPP 12 | #define ASIO_SIGNAL_SET_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | #include "asio/basic_signal_set.hpp" 20 | 21 | namespace asio { 22 | 23 | /// Typedef for the typical usage of a signal set. 24 | typedef basic_signal_set<> signal_set; 25 | 26 | } // namespace asio 27 | 28 | #endif // ASIO_SIGNAL_SET_HPP 29 | -------------------------------------------------------------------------------- /vendor/asio/ssl.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ssl.hpp 3 | // ~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_SSL_HPP 12 | #define ASIO_SSL_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/ssl/basic_context.hpp" 19 | #include "asio/ssl/context.hpp" 20 | #include "asio/ssl/context_base.hpp" 21 | #include "asio/ssl/context_service.hpp" 22 | #include "asio/ssl/error.hpp" 23 | #include "asio/ssl/rfc2818_verification.hpp" 24 | #include "asio/ssl/stream.hpp" 25 | #include "asio/ssl/stream_base.hpp" 26 | #include "asio/ssl/stream_service.hpp" 27 | #include "asio/ssl/verify_context.hpp" 28 | #include "asio/ssl/verify_mode.hpp" 29 | 30 | #endif // ASIO_SSL_HPP 31 | -------------------------------------------------------------------------------- /vendor/asio/streambuf.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // streambuf.hpp 3 | // ~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_STREAMBUF_HPP 12 | #define ASIO_STREAMBUF_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if !defined(ASIO_NO_IOSTREAM) 21 | 22 | #include "asio/basic_streambuf.hpp" 23 | 24 | namespace asio { 25 | 26 | /// Typedef for the typical usage of basic_streambuf. 27 | typedef basic_streambuf<> streambuf; 28 | 29 | } // namespace asio 30 | 31 | #endif // !defined(ASIO_NO_IOSTREAM) 32 | 33 | #endif // ASIO_STREAMBUF_HPP 34 | -------------------------------------------------------------------------------- /vendor/asio/unyield.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // unyield.hpp 3 | // ~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifdef reenter 12 | # undef reenter 13 | #endif 14 | 15 | #ifdef yield 16 | # undef yield 17 | #endif 18 | 19 | #ifdef fork 20 | # undef fork 21 | #endif 22 | -------------------------------------------------------------------------------- /vendor/asio/version.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // version.hpp 3 | // ~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_VERSION_HPP 12 | #define ASIO_VERSION_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | // ASIO_VERSION % 100 is the sub-minor version 19 | // ASIO_VERSION / 100 % 1000 is the minor version 20 | // ASIO_VERSION / 100000 is the major version 21 | #define ASIO_VERSION 101008 // 1.10.8 22 | 23 | #endif // ASIO_VERSION_HPP 24 | -------------------------------------------------------------------------------- /vendor/asio/wait_traits.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // wait_traits.hpp 3 | // ~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_WAIT_TRAITS_HPP 12 | #define ASIO_WAIT_TRAITS_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/push_options.hpp" 19 | 20 | namespace asio { 21 | 22 | /// Wait traits suitable for use with the basic_waitable_timer class template. 23 | template 24 | struct wait_traits 25 | { 26 | /// Convert a clock duration into a duration used for waiting. 27 | /** 28 | * @returns @c d. 29 | */ 30 | static typename Clock::duration to_wait_duration( 31 | const typename Clock::duration& d) 32 | { 33 | return d; 34 | } 35 | }; 36 | 37 | } // namespace asio 38 | 39 | #include "asio/detail/pop_options.hpp" 40 | 41 | #endif // ASIO_WAIT_TRAITS_HPP 42 | -------------------------------------------------------------------------------- /vendor/asio/windows/object_handle.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // windows/object_handle.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // Copyright (c) 2011 Boris Schaeling (boris@highscore.de) 7 | // 8 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 9 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | 12 | #ifndef ASIO_WINDOWS_OBJECT_HANDLE_HPP 13 | #define ASIO_WINDOWS_OBJECT_HANDLE_HPP 14 | 15 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 | # pragma once 17 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 | 19 | #include "asio/detail/config.hpp" 20 | 21 | #if defined(ASIO_HAS_WINDOWS_OBJECT_HANDLE) \ 22 | || defined(GENERATING_DOCUMENTATION) 23 | 24 | #include "asio/windows/basic_object_handle.hpp" 25 | 26 | namespace asio { 27 | namespace windows { 28 | 29 | /// Typedef for the typical usage of an object handle. 30 | typedef basic_object_handle<> object_handle; 31 | 32 | } // namespace windows 33 | } // namespace asio 34 | 35 | #endif // defined(ASIO_HAS_WINDOWS_OBJECT_HANDLE) 36 | // || defined(GENERATING_DOCUMENTATION) 37 | 38 | #endif // ASIO_WINDOWS_OBJECT_HANDLE_HPP 39 | -------------------------------------------------------------------------------- /vendor/asio/windows/random_access_handle.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // windows/random_access_handle.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_HPP 12 | #define ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \ 21 | || defined(GENERATING_DOCUMENTATION) 22 | 23 | #include "asio/windows/basic_random_access_handle.hpp" 24 | 25 | namespace asio { 26 | namespace windows { 27 | 28 | /// Typedef for the typical usage of a random-access handle. 29 | typedef basic_random_access_handle<> random_access_handle; 30 | 31 | } // namespace windows 32 | } // namespace asio 33 | 34 | #endif // defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) 35 | // || defined(GENERATING_DOCUMENTATION) 36 | 37 | #endif // ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_HPP 38 | -------------------------------------------------------------------------------- /vendor/asio/windows/stream_handle.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // windows/stream_handle.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_WINDOWS_STREAM_HANDLE_HPP 12 | #define ASIO_WINDOWS_STREAM_HANDLE_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #if defined(ASIO_HAS_WINDOWS_STREAM_HANDLE) \ 21 | || defined(GENERATING_DOCUMENTATION) 22 | 23 | #include "asio/windows/basic_stream_handle.hpp" 24 | 25 | namespace asio { 26 | namespace windows { 27 | 28 | /// Typedef for the typical usage of a stream-oriented handle. 29 | typedef basic_stream_handle<> stream_handle; 30 | 31 | } // namespace windows 32 | } // namespace asio 33 | 34 | #endif // defined(ASIO_HAS_WINDOWS_STREAM_HANDLE) 35 | // || defined(GENERATING_DOCUMENTATION) 36 | 37 | #endif // ASIO_WINDOWS_STREAM_HANDLE_HPP 38 | -------------------------------------------------------------------------------- /vendor/asio/yield.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // yield.hpp 3 | // ~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #include "coroutine.hpp" 12 | 13 | #ifndef reenter 14 | # define reenter(c) ASIO_CORO_REENTER(c) 15 | #endif 16 | 17 | #ifndef yield 18 | # define yield ASIO_CORO_YIELD 19 | #endif 20 | 21 | #ifndef fork 22 | # define fork ASIO_CORO_FORK 23 | #endif 24 | -------------------------------------------------------------------------------- /vendor/pybind11/.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles 3 | Makefile 4 | cmake_install.cmake 5 | .DS_Store 6 | *.so 7 | *.pyd 8 | *.dll 9 | *.sln 10 | *.sdf 11 | *.opensdf 12 | *.vcxproj 13 | *.filters 14 | example.dir 15 | Win32 16 | x64 17 | Release 18 | Debug 19 | .vs 20 | CTestTestfile.cmake 21 | Testing 22 | autogen 23 | MANIFEST 24 | /.ninja_* 25 | /*.ninja 26 | /docs/.build 27 | *.py[co] 28 | *.egg-info 29 | *~ 30 | .DS_Store 31 | /dist 32 | /build 33 | /cmake/ 34 | .cache/ 35 | sosize-*.txt 36 | pybind11Config*.cmake 37 | pybind11Targets.cmake 38 | -------------------------------------------------------------------------------- /vendor/pybind11/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tools/clang"] 2 | path = tools/clang 3 | url = https://github.com/wjakob/clang-cindex-python3 4 | -------------------------------------------------------------------------------- /vendor/pybind11/.readthedocs.yml: -------------------------------------------------------------------------------- 1 | python: 2 | version: 3 3 | requirements_file: docs/requirements.txt 4 | -------------------------------------------------------------------------------- /vendor/pybind11/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Make sure you've completed the following steps before submitting your issue -- thank you! 2 | 3 | 1. Check if your question has already been answered in the [FAQ](http://pybind11.readthedocs.io/en/latest/faq.html) section. 4 | 2. Make sure you've read the [documentation](http://pybind11.readthedocs.io/en/latest/). Your issue may be addressed there. 5 | 3. If those resources didn't help and you only have a short question (not a bug report), consider asking in the [Gitter chat room](https://gitter.im/pybind/Lobby). 6 | 4. If you have a genuine bug report or a more complex question which is not answered in the previous items (or not suitable for chat), please fill in the details below. 7 | 5. Include a self-contained and minimal piece of code that reproduces the problem. If that's not possible, try to make the description as clear as possible. 8 | 9 | *After reading, remove this checklist and the template text in parentheses below.* 10 | 11 | ## Issue description 12 | 13 | (Provide a short description, state the expected behavior and what actually happens.) 14 | 15 | ## Reproducible example code 16 | 17 | (The code should be minimal, have no external dependencies, isolate the function(s) that cause breakage. Submit matched and complete C++ and Python snippets that can be easily compiled and run to diagnose the issue.) 18 | -------------------------------------------------------------------------------- /vendor/pybind11/MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include include/pybind11 *.h 2 | include LICENSE README.md CONTRIBUTING.md 3 | -------------------------------------------------------------------------------- /vendor/pybind11/include/pybind11/common.h: -------------------------------------------------------------------------------- 1 | #include "detail/common.h" 2 | #warning "Including 'common.h' is deprecated. It will be removed in v3.0. Use 'pybind11.h'." 3 | -------------------------------------------------------------------------------- /vendor/pybind11/include/pybind11/detail/typeid.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/detail/typeid.h: Compiler-independent access to type identifiers 3 | 4 | Copyright (c) 2016 Wenzel Jakob 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include 13 | #include 14 | 15 | #if defined(__GNUG__) 16 | #include 17 | #endif 18 | 19 | NAMESPACE_BEGIN(PYBIND11_NAMESPACE) 20 | NAMESPACE_BEGIN(detail) 21 | /// Erase all occurrences of a substring 22 | inline void erase_all(std::string &string, const std::string &search) { 23 | for (size_t pos = 0;;) { 24 | pos = string.find(search, pos); 25 | if (pos == std::string::npos) break; 26 | string.erase(pos, search.length()); 27 | } 28 | } 29 | 30 | PYBIND11_NOINLINE inline void clean_type_id(std::string &name) { 31 | #if defined(__GNUG__) 32 | int status = 0; 33 | std::unique_ptr res { 34 | abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status), std::free }; 35 | if (status == 0) 36 | name = res.get(); 37 | #else 38 | detail::erase_all(name, "class "); 39 | detail::erase_all(name, "struct "); 40 | detail::erase_all(name, "enum "); 41 | #endif 42 | detail::erase_all(name, "pybind11::"); 43 | } 44 | NAMESPACE_END(detail) 45 | 46 | /// Return a string representation of a C++ type 47 | template static std::string type_id() { 48 | std::string name(typeid(T).name()); 49 | detail::clean_type_id(name); 50 | return name; 51 | } 52 | 53 | NAMESPACE_END(PYBIND11_NAMESPACE) 54 | -------------------------------------------------------------------------------- /vendor/pybind11/pybind11/__init__.py: -------------------------------------------------------------------------------- 1 | from ._version import version_info, __version__ # noqa: F401 imported but unused 2 | 3 | 4 | def get_include(*args, **kwargs): 5 | import os 6 | try: 7 | from pip import locations 8 | return os.path.dirname( 9 | locations.distutils_scheme('pybind11', *args, **kwargs)['headers']) 10 | except ImportError: 11 | return 'include' 12 | -------------------------------------------------------------------------------- /vendor/pybind11/pybind11/__main__.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | 3 | import argparse 4 | import sys 5 | import sysconfig 6 | 7 | from . import get_include 8 | 9 | 10 | def print_includes(): 11 | dirs = [sysconfig.get_path('include'), 12 | sysconfig.get_path('platinclude'), 13 | get_include(), 14 | get_include(True)] 15 | 16 | # Make unique but preserve order 17 | unique_dirs = [] 18 | for d in dirs: 19 | if d not in unique_dirs: 20 | unique_dirs.append(d) 21 | 22 | print(' '.join('-I' + d for d in unique_dirs)) 23 | 24 | 25 | def main(): 26 | parser = argparse.ArgumentParser(prog='python -m pybind11') 27 | parser.add_argument('--includes', action='store_true', 28 | help='Include flags for both pybind11 and Python headers.') 29 | args = parser.parse_args() 30 | if not sys.argv[1:]: 31 | parser.print_help() 32 | if args.includes: 33 | print_includes() 34 | 35 | 36 | if __name__ == '__main__': 37 | main() 38 | -------------------------------------------------------------------------------- /vendor/pybind11/pybind11/_version.py: -------------------------------------------------------------------------------- 1 | version_info = (2, 3, 'dev0') 2 | __version__ = '.'.join(map(str, version_info)) 3 | -------------------------------------------------------------------------------- /vendor/pybind11/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 3 | 4 | [flake8] 5 | max-line-length = 99 6 | show_source = True 7 | exclude = .git, __pycache__, build, dist, docs, tools, venv 8 | ignore = 9 | # required for pretty matrix formating: multiple spaces after `,` and `[` 10 | E201, E241 11 | -------------------------------------------------------------------------------- /vendor/pybind11/tools/clang/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | *.pyc 4 | __pycache__ 5 | -------------------------------------------------------------------------------- /vendor/pybind11/tools/clang/README.md: -------------------------------------------------------------------------------- 1 | This is simply clang's Python bindings (clang.cindex) ported to Python 3. Please see http://llvm.org/svn/llvm-project/cfe/trunk/bindings/python/ for the original project. 2 | 3 | -------------------------------------------------------------------------------- /vendor/pybind11/tools/clang/__init__.py: -------------------------------------------------------------------------------- 1 | #===- __init__.py - Clang Python Bindings --------------------*- python -*--===# 2 | # 3 | # The LLVM Compiler Infrastructure 4 | # 5 | # This file is distributed under the University of Illinois Open Source 6 | # License. See LICENSE.TXT for details. 7 | # 8 | #===------------------------------------------------------------------------===# 9 | 10 | r""" 11 | Clang Library Bindings 12 | ====================== 13 | 14 | This package provides access to the Clang compiler and libraries. 15 | 16 | The available modules are: 17 | 18 | cindex 19 | 20 | Bindings for the Clang indexing library. 21 | """ 22 | 23 | __all__ = ['cindex'] 24 | 25 | -------------------------------------------------------------------------------- /vendor/pybind11/tools/clang/enumerations.py: -------------------------------------------------------------------------------- 1 | #===- enumerations.py - Python Enumerations ------------------*- python -*--===# 2 | # 3 | # The LLVM Compiler Infrastructure 4 | # 5 | # This file is distributed under the University of Illinois Open Source 6 | # License. See LICENSE.TXT for details. 7 | # 8 | #===------------------------------------------------------------------------===# 9 | 10 | """ 11 | Clang Enumerations 12 | ================== 13 | 14 | This module provides static definitions of enumerations that exist in libclang. 15 | 16 | Enumerations are typically defined as a list of tuples. The exported values are 17 | typically munged into other types or classes at module load time. 18 | 19 | All enumerations are centrally defined in this file so they are all grouped 20 | together and easier to audit. And, maybe even one day this file will be 21 | automatically generated by scanning the libclang headers! 22 | """ 23 | 24 | # Maps to CXTokenKind. Note that libclang maintains a separate set of token 25 | # enumerations from the C++ API. 26 | TokenKinds = [ 27 | ('PUNCTUATION', 0), 28 | ('KEYWORD', 1), 29 | ('IDENTIFIER', 2), 30 | ('LITERAL', 3), 31 | ('COMMENT', 4), 32 | ] 33 | 34 | __all__ = ['TokenKinds'] 35 | -------------------------------------------------------------------------------- /vendor/pybind11/tools/libsize.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | import os 3 | import sys 4 | 5 | # Internal build script for generating debugging test .so size. 6 | # Usage: 7 | # python libsize.py file.so save.txt -- displays the size of file.so and, if save.txt exists, compares it to the 8 | # size in it, then overwrites save.txt with the new size for future runs. 9 | 10 | if len(sys.argv) != 3: 11 | sys.exit("Invalid arguments: usage: python libsize.py file.so save.txt") 12 | 13 | lib = sys.argv[1] 14 | save = sys.argv[2] 15 | 16 | if not os.path.exists(lib): 17 | sys.exit("Error: requested file ({}) does not exist".format(lib)) 18 | 19 | libsize = os.path.getsize(lib) 20 | 21 | print("------", os.path.basename(lib), "file size:", libsize, end='') 22 | 23 | if os.path.exists(save): 24 | with open(save) as sf: 25 | oldsize = int(sf.readline()) 26 | 27 | if oldsize > 0: 28 | change = libsize - oldsize 29 | if change == 0: 30 | print(" (no change)") 31 | else: 32 | print(" (change of {:+} bytes = {:+.2%})".format(change, change / oldsize)) 33 | else: 34 | print() 35 | 36 | with open(save, 'w') as sf: 37 | sf.write(str(libsize)) 38 | 39 | -------------------------------------------------------------------------------- /vendor/websocketpp/CMakeFiles/CMakeDirectoryInformation.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.8 3 | 4 | # Relative path conversion top directories. 5 | set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/yuxinwu/ELFs/ELF/vendor/websocketpp-github") 6 | set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/yuxinwu/ELFs/ELF/vendor/websocketpp-github") 7 | 8 | # Force unix paths in dependencies. 9 | set(CMAKE_FORCE_UNIX_PATHS 1) 10 | 11 | 12 | # The C and CXX include file regular expressions for this directory. 13 | set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$") 14 | set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$") 15 | set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN}) 16 | set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN}) 17 | -------------------------------------------------------------------------------- /vendor/websocketpp/CMakeFiles/progress.marks: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /vendor/websocketpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | init_target("websocketpp") 2 | final_target () 3 | -------------------------------------------------------------------------------- /vendor/websocketpp/CTestTestfile.cmake: -------------------------------------------------------------------------------- 1 | # CMake generated Testfile for 2 | # Source directory: /home/yuxinwu/ELFs/ELF/vendor/websocketpp-github/websocketpp 3 | # Build directory: /home/yuxinwu/ELFs/ELF/vendor/websocketpp-github/websocketpp 4 | # 5 | # This file includes the relevant testing commands required for 6 | # testing this directory and lists subdirectories to be tested as well. 7 | --------------------------------------------------------------------------------