├── MyActor.sln ├── MyActor ├── Makefile ├── MyActor.cpp ├── MyActor_linux-Debug.vgdbsettings ├── MyActor_linux-Release.vgdbsettings ├── MyActor_linux.vcxproj ├── MyActor_linux.vcxproj.filters ├── MyActor_linux.vcxproj.user ├── MyActor_win.vcxproj ├── MyActor_win.vcxproj.filters ├── MyActor_win.vcxproj.user ├── actor.cpp ├── actor │ ├── actor_cpp.h │ ├── actor_mutex.cpp │ ├── actor_mutex.h │ ├── actor_socket.cpp │ ├── actor_socket.h │ ├── actor_timer.cpp │ ├── actor_timer.h │ ├── async_timer.cpp │ ├── async_timer.h │ ├── bind_node_run.cpp │ ├── bind_node_run.h │ ├── bind_qt_run.cpp │ ├── bind_qt_run.h │ ├── channel.h │ ├── check_actor_stack.h │ ├── context_pool.cpp │ ├── context_pool.h │ ├── context_yield.cpp │ ├── context_yield.h │ ├── generator.cpp │ ├── generator.h │ ├── io_engine.cpp │ ├── io_engine.h │ ├── lambda_ref.h │ ├── lib │ │ ├── fcontext_x64.lib │ │ ├── fcontext_x86.lib │ │ ├── libfcontext_aarch64.a │ │ ├── libfcontext_armhf32.a │ │ ├── libfcontext_armsf32.a │ │ ├── libfcontext_x64.a │ │ └── libfcontext_x86.a │ ├── mem_pool.h │ ├── msg_queue.h │ ├── my_actor.cpp │ ├── my_actor.h │ ├── qt_strand.cpp │ ├── qt_strand.h │ ├── run_strand.h │ ├── run_thread.cpp │ ├── run_thread.h │ ├── scattered.cpp │ ├── scattered.h │ ├── shared_strand.cpp │ ├── shared_strand.h │ ├── stack_object.h │ ├── strand_ex.cpp │ ├── strand_ex.h │ ├── trace.h │ ├── trace_stack.cpp │ ├── trace_stack.h │ ├── try_move.h │ ├── tuple_option.h │ ├── uv_strand.cpp │ ├── uv_strand.h │ ├── waitable_timer.cpp │ ├── waitable_timer.h │ ├── wrapped_capture.h │ ├── wrapped_dispatch_handler.h │ ├── wrapped_distribute_handler.h │ ├── wrapped_next_tick_handler.h │ ├── wrapped_post_handler.h │ └── wrapped_try_tick_handler.h ├── debug.mak └── release.mak ├── MyActor_arm_linux ├── Makefile ├── MyActor_arm_linux-Debug.vgdbsettings ├── MyActor_arm_linux-Release.vgdbsettings ├── MyActor_arm_linux.vcxproj ├── MyActor_arm_linux.vcxproj.filters ├── debug.mak └── release.mak ├── MyActor_mingw ├── Makefile ├── MyActor_mingw-Debug.vgdbsettings ├── MyActor_mingw-Release.vgdbsettings ├── MyActor_mingw.vcxproj ├── MyActor_mingw.vcxproj.filters ├── debug.mak └── release.mak └── readme.txt /MyActor.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyActor_linux", "MyActor\MyActor_linux.vcxproj", "{9573870F-13B0-421C-B6B0-9665B02E8508}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyActor_win", "MyActor\MyActor_win.vcxproj", "{F46F0326-E7FC-4E79-95D6-69F5F709CCAF}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyActor_mingw", "MyActor_mingw\MyActor_mingw.vcxproj", "{27FDE187-1B88-4A88-BED2-5B8FFCD4C0D0}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyActor_arm_linux", "MyActor_arm_linux\MyActor_arm_linux.vcxproj", "{5B0AE8CB-4AAA-435D-9CAC-C20F1CCCFC6A}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Win32 = Debug|Win32 17 | Debug|x64 = Debug|x64 18 | Release|Win32 = Release|Win32 19 | Release|x64 = Release|x64 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {9573870F-13B0-421C-B6B0-9665B02E8508}.Debug|Win32.ActiveCfg = Debug|Win32 23 | {9573870F-13B0-421C-B6B0-9665B02E8508}.Debug|Win32.Build.0 = Debug|Win32 24 | {9573870F-13B0-421C-B6B0-9665B02E8508}.Debug|x64.ActiveCfg = Debug|x64 25 | {9573870F-13B0-421C-B6B0-9665B02E8508}.Debug|x64.Build.0 = Debug|x64 26 | {9573870F-13B0-421C-B6B0-9665B02E8508}.Release|Win32.ActiveCfg = Release|Win32 27 | {9573870F-13B0-421C-B6B0-9665B02E8508}.Release|Win32.Build.0 = Release|Win32 28 | {9573870F-13B0-421C-B6B0-9665B02E8508}.Release|x64.ActiveCfg = Release|x64 29 | {9573870F-13B0-421C-B6B0-9665B02E8508}.Release|x64.Build.0 = Release|x64 30 | {F46F0326-E7FC-4E79-95D6-69F5F709CCAF}.Debug|Win32.ActiveCfg = Debug|Win32 31 | {F46F0326-E7FC-4E79-95D6-69F5F709CCAF}.Debug|Win32.Build.0 = Debug|Win32 32 | {F46F0326-E7FC-4E79-95D6-69F5F709CCAF}.Debug|x64.ActiveCfg = Debug|x64 33 | {F46F0326-E7FC-4E79-95D6-69F5F709CCAF}.Debug|x64.Build.0 = Debug|x64 34 | {F46F0326-E7FC-4E79-95D6-69F5F709CCAF}.Release|Win32.ActiveCfg = Release|Win32 35 | {F46F0326-E7FC-4E79-95D6-69F5F709CCAF}.Release|Win32.Build.0 = Release|Win32 36 | {F46F0326-E7FC-4E79-95D6-69F5F709CCAF}.Release|x64.ActiveCfg = Release|x64 37 | {F46F0326-E7FC-4E79-95D6-69F5F709CCAF}.Release|x64.Build.0 = Release|x64 38 | {27FDE187-1B88-4A88-BED2-5B8FFCD4C0D0}.Debug|Win32.ActiveCfg = Debug|Win32 39 | {27FDE187-1B88-4A88-BED2-5B8FFCD4C0D0}.Debug|Win32.Build.0 = Debug|Win32 40 | {27FDE187-1B88-4A88-BED2-5B8FFCD4C0D0}.Debug|x64.ActiveCfg = Debug|Win32 41 | {27FDE187-1B88-4A88-BED2-5B8FFCD4C0D0}.Release|Win32.ActiveCfg = Release|Win32 42 | {27FDE187-1B88-4A88-BED2-5B8FFCD4C0D0}.Release|Win32.Build.0 = Release|Win32 43 | {27FDE187-1B88-4A88-BED2-5B8FFCD4C0D0}.Release|x64.ActiveCfg = Release|Win32 44 | {5B0AE8CB-4AAA-435D-9CAC-C20F1CCCFC6A}.Debug|Win32.ActiveCfg = Debug|Win32 45 | {5B0AE8CB-4AAA-435D-9CAC-C20F1CCCFC6A}.Debug|Win32.Build.0 = Debug|Win32 46 | {5B0AE8CB-4AAA-435D-9CAC-C20F1CCCFC6A}.Debug|x64.ActiveCfg = Debug|Win32 47 | {5B0AE8CB-4AAA-435D-9CAC-C20F1CCCFC6A}.Release|Win32.ActiveCfg = Release|Win32 48 | {5B0AE8CB-4AAA-435D-9CAC-C20F1CCCFC6A}.Release|Win32.Build.0 = Release|Win32 49 | {5B0AE8CB-4AAA-435D-9CAC-C20F1CCCFC6A}.Release|x64.ActiveCfg = Release|Win32 50 | EndGlobalSection 51 | GlobalSection(SolutionProperties) = preSolution 52 | HideSolutionNode = FALSE 53 | EndGlobalSection 54 | EndGlobal 55 | -------------------------------------------------------------------------------- /MyActor/Makefile: -------------------------------------------------------------------------------- 1 | #Generated by VisualGDB project wizard. 2 | #Note: VisualGDB will automatically update this file when you add new sources to the project. 3 | #All other changes you make in this file will be preserved. 4 | #Visit http://visualgdb.com/makefiles for more details 5 | 6 | #VisualGDB: AutoSourceFiles #<--- remove this line to disable auto-updating of SOURCEFILES and EXTERNAL_LIBS 7 | 8 | TARGETNAME := MyActor_linux 9 | #TARGETTYPE can be APP, STATIC or SHARED 10 | TARGETTYPE := APP 11 | 12 | to_lowercase = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) 13 | 14 | CONFIG ?= DEBUG 15 | 16 | CONFIGURATION_FLAGS_FILE := $(call to_lowercase,$(CONFIG)).mak 17 | 18 | include $(CONFIGURATION_FLAGS_FILE) 19 | #LINKER_SCRIPT defined inside the configuration file (e.g. debug.mak) should override any linker scripts defined in shared .mak files 20 | CONFIGURATION_LINKER_SCRIPT := $(LINKER_SCRIPT) 21 | 22 | include $(ADDITIONAL_MAKE_FILES) 23 | 24 | ifneq ($(CONFIGURATION_LINKER_SCRIPT),) 25 | LINKER_SCRIPT := $(CONFIGURATION_LINKER_SCRIPT) 26 | endif 27 | 28 | ifneq ($(LINKER_SCRIPT),) 29 | LDFLAGS += -T$(LINKER_SCRIPT) 30 | endif 31 | 32 | ifeq ($(BINARYDIR),) 33 | error: 34 | $(error Invalid configuration, please check your inputs) 35 | endif 36 | 37 | SOURCEFILES := actor.cpp MyActor.cpp 38 | EXTERNAL_LIBS := 39 | EXTERNAL_LIBS_COPIED := $(foreach lib, $(EXTERNAL_LIBS),$(BINARYDIR)/$(notdir $(lib))) 40 | 41 | CFLAGS += $(COMMONFLAGS) 42 | CXXFLAGS += $(COMMONFLAGS) 43 | ASFLAGS += $(COMMONFLAGS) 44 | LDFLAGS += $(COMMONFLAGS) 45 | 46 | CFLAGS += $(addprefix -I,$(INCLUDE_DIRS)) 47 | CXXFLAGS += $(addprefix -I,$(INCLUDE_DIRS)) 48 | 49 | CFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS)) 50 | CXXFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS)) 51 | ASFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS)) 52 | 53 | CXXFLAGS += $(addprefix -framework ,$(MACOS_FRAMEWORKS)) 54 | CFLAGS += $(addprefix -framework ,$(MACOS_FRAMEWORKS)) 55 | LDFLAGS += $(addprefix -framework ,$(MACOS_FRAMEWORKS)) 56 | 57 | LDFLAGS += $(addprefix -L,$(LIBRARY_DIRS)) 58 | 59 | ifeq ($(GENERATE_MAP_FILE),1) 60 | LDFLAGS += -Wl,-Map=$(BINARYDIR)/$(basename $(TARGETNAME)).map 61 | endif 62 | 63 | LIBRARY_LDFLAGS = $(addprefix -l,$(LIBRARY_NAMES)) 64 | 65 | ifeq ($(IS_LINUX_PROJECT),1) 66 | RPATH_PREFIX := -Wl,--rpath='$$ORIGIN/../ 67 | LIBRARY_LDFLAGS += $(EXTERNAL_LIBS) 68 | LIBRARY_LDFLAGS += -Wl,--rpath='$$ORIGIN' 69 | LIBRARY_LDFLAGS += $(addsuffix ',$(addprefix $(RPATH_PREFIX),$(dir $(EXTERNAL_LIBS)))) 70 | 71 | ifeq ($(TARGETTYPE),SHARED) 72 | CFLAGS += -fPIC 73 | CXXFLAGS += -fPIC 74 | ASFLAGS += -fPIC 75 | LIBRARY_LDFLAGS += -Wl,-soname,$(TARGETNAME) 76 | endif 77 | 78 | ifneq ($(LINUX_PACKAGES),) 79 | PACKAGE_CFLAGS := $(foreach pkg,$(LINUX_PACKAGES),$(shell pkg-config --cflags $(pkg))) 80 | PACKAGE_LDFLAGS := $(foreach pkg,$(LINUX_PACKAGES),$(shell pkg-config --libs $(pkg))) 81 | CFLAGS += $(PACKAGE_CFLAGS) 82 | CXXFLAGS += $(PACKAGE_CFLAGS) 83 | LIBRARY_LDFLAGS += $(PACKAGE_LDFLAGS) 84 | endif 85 | else 86 | LIBRARY_LDFLAGS += $(EXTERNAL_LIBS) 87 | endif 88 | 89 | LIBRARY_LDFLAGS += $(ADDITIONAL_LINKER_INPUTS) 90 | 91 | all_make_files := $(firstword $(MAKEFILE_LIST)) $(CONFIGURATION_FLAGS_FILE) $(ADDITIONAL_MAKE_FILES) 92 | 93 | ifeq ($(STARTUPFILES),) 94 | all_source_files := $(SOURCEFILES) 95 | else 96 | all_source_files := $(STARTUPFILES) $(filter-out $(STARTUPFILES),$(SOURCEFILES)) 97 | endif 98 | 99 | source_obj1 := $(all_source_files:.cpp=.o) 100 | source_obj2 := $(source_obj1:.c=.o) 101 | source_obj3 := $(source_obj2:.s=.o) 102 | source_obj4 := $(source_obj3:.S=.o) 103 | source_obj5 := $(source_obj4:.cc=.o) 104 | source_objs := $(source_obj5:.cxx=.o) 105 | 106 | all_objs := $(addprefix $(BINARYDIR)/, $(notdir $(source_objs))) 107 | 108 | PRIMARY_OUTPUTS := 109 | 110 | ifeq ($(GENERATE_BIN_FILE),1) 111 | PRIMARY_OUTPUTS += $(BINARYDIR)/$(basename $(TARGETNAME)).bin 112 | endif 113 | 114 | ifeq ($(GENERATE_IHEX_FILE),1) 115 | PRIMARY_OUTPUTS += $(BINARYDIR)/$(basename $(TARGETNAME)).ihex 116 | endif 117 | 118 | ifeq ($(PRIMARY_OUTPUTS),) 119 | PRIMARY_OUTPUTS := $(BINARYDIR)/$(TARGETNAME) 120 | endif 121 | 122 | all: $(PRIMARY_OUTPUTS) 123 | 124 | $(BINARYDIR)/$(basename $(TARGETNAME)).bin: $(BINARYDIR)/$(TARGETNAME) 125 | $(OBJCOPY) -O binary $< $@ 126 | 127 | $(BINARYDIR)/$(basename $(TARGETNAME)).ihex: $(BINARYDIR)/$(TARGETNAME) 128 | $(OBJCOPY) -O ihex $< $@ 129 | 130 | ifeq ($(TARGETTYPE),APP) 131 | $(BINARYDIR)/$(TARGETNAME): $(all_objs) $(EXTERNAL_LIBS) 132 | $(LD) -o $@ $(LDFLAGS) $(START_GROUP) $(all_objs) $(LIBRARY_LDFLAGS) $(END_GROUP) 133 | endif 134 | 135 | ifeq ($(TARGETTYPE),SHARED) 136 | $(BINARYDIR)/$(TARGETNAME): $(all_objs) $(EXTERNAL_LIBS) 137 | $(LD) -shared -o $@ $(LDFLAGS) $(START_GROUP) $(all_objs) $(LIBRARY_LDFLAGS) $(END_GROUP) 138 | endif 139 | 140 | ifeq ($(TARGETTYPE),STATIC) 141 | $(BINARYDIR)/$(TARGETNAME): $(all_objs) 142 | $(AR) -r $@ $^ 143 | endif 144 | 145 | -include $(all_objs:.o=.dep) 146 | 147 | clean: 148 | ifeq ($(USE_DEL_TO_CLEAN),1) 149 | del /S /Q $(BINARYDIR) 150 | else 151 | rm -rf $(BINARYDIR) 152 | endif 153 | 154 | $(BINARYDIR): 155 | mkdir $(BINARYDIR) 156 | 157 | #VisualGDB: FileSpecificTemplates #<--- VisualGDB will use the following lines to define rules for source files in subdirectories 158 | $(BINARYDIR)/%.o : %.cpp $(all_make_files) |$(BINARYDIR) 159 | $(CXX) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 160 | 161 | $(BINARYDIR)/%.o : %.c $(all_make_files) |$(BINARYDIR) 162 | $(CC) $(CFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 163 | 164 | $(BINARYDIR)/%.o : %.S $(all_make_files) |$(BINARYDIR) 165 | $(CC) $(CFLAGS) $(ASFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 166 | 167 | $(BINARYDIR)/%.o : %.s $(all_make_files) |$(BINARYDIR) 168 | $(CC) $(CFLAGS) $(ASFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 169 | 170 | $(BINARYDIR)/%.o : %.cc $(all_make_files) |$(BINARYDIR) 171 | $(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 172 | 173 | $(BINARYDIR)/%.o : %.cxx $(all_make_files) |$(BINARYDIR) 174 | $(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 175 | 176 | #VisualGDB: GeneratedRules #<--- All lines below are auto-generated 177 | -------------------------------------------------------------------------------- /MyActor/MyActor_linux-Debug.vgdbsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | Debug 4 | 5 | 6 | 7 | RemoteUnix 8 | 9 | 10 | 127.0.0.1 11 | SSH 12 | ham 13 | 14 | 15 | false 16 | 17 | 127.0.0.1 18 | SSH 19 | ham 20 | 21 | $(ProjectDir) 22 | /tmp/VisualGDB/$(ProjectDirUnixStyle) 23 | 24 | *.cpp 25 | *.h 26 | *.c 27 | *.cc 28 | *.cxx 29 | *.mak 30 | Makefile 31 | *.a 32 | 33 | true 34 | true 35 | 36 | 37 | false 38 | false 39 | false 40 | false 41 | false 42 | $(ProjectDir) 43 | 44 | 45 | Makefile 46 | Debug 47 | -j2 48 | 49 | Custom toolchain 50 | /usr/gcc-4.9.3/bin/ 51 | true 52 | /usr/gcc-4.9.3/bin/gcc 53 | /usr/gcc-4.9.3/bin/g++ 54 | /usr/gcc-4.9.3/bin/gdb 55 | /usr/gcc-4.9.3/bin/ar 56 | /usr/gcc-4.9.3/bin/objcopy 57 | make 58 | false 59 | false 60 | 61 | 62 | false 63 | 64 | 127.0.0.1 65 | SSH 66 | ham 67 | 68 | make 69 | $(BuildDir) 70 | 71 | 72 | 73 | LANG 74 | en_US.UTF-8 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | false 84 | false 85 | true 86 | false 87 | false 88 | false 89 | false 90 | true 91 | false 92 | None 93 | 94 | false 95 | false 96 | false 97 | false 98 | false 99 | false 100 | false 101 | false 102 | false 103 | 104 | false 105 | false 106 | main 107 | true 108 | false 109 | false 110 | false 111 | false 112 | 113 | 114 | 115 | 116 | 117 | LANG 118 | en_US.UTF-8 119 | 120 | 121 | 122 | $(TargetPath) 123 | 2000 124 | 125 | 126 | false 127 | Local 128 | false 129 | false 130 | Auto 131 | true 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | Default 144 | 145 | 146 | 147 | true 148 | 149 | 150 | 151 | 152 | Unknown 153 | 154 | true 155 | 156 | 157 | -------------------------------------------------------------------------------- /MyActor/MyActor_linux-Release.vgdbsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | Release 4 | 5 | 6 | 7 | RemoteUnix 8 | 9 | 10 | 127.0.0.1 11 | SSH 12 | ham 13 | 14 | 15 | false 16 | 17 | 127.0.0.1 18 | SSH 19 | ham 20 | 21 | $(ProjectDir) 22 | /tmp/VisualGDB/$(ProjectDirUnixStyle) 23 | 24 | *.cpp 25 | *.h 26 | *.c 27 | *.cc 28 | *.cxx 29 | *.mak 30 | Makefile 31 | *.a 32 | 33 | true 34 | true 35 | 36 | 37 | false 38 | false 39 | false 40 | false 41 | false 42 | $(ProjectDir) 43 | 44 | 45 | Makefile 46 | Release 47 | -j2 48 | 49 | Custom toolchain 50 | /usr/gcc-4.9.3/bin/ 51 | true 52 | /usr/gcc-4.9.3/bin/gcc 53 | /usr/gcc-4.9.3/bin/g++ 54 | /usr/gcc-4.9.3/bin/gdb 55 | /usr/gcc-4.9.3/bin/ar 56 | /usr/gcc-4.9.3/bin/objcopy 57 | make 58 | false 59 | false 60 | 61 | 62 | false 63 | 64 | 127.0.0.1 65 | SSH 66 | ham 67 | 68 | make 69 | $(BuildDir) 70 | 71 | 72 | 73 | LANG 74 | en_US.UTF-8 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | false 84 | false 85 | true 86 | false 87 | false 88 | false 89 | false 90 | true 91 | false 92 | None 93 | 94 | false 95 | false 96 | false 97 | false 98 | false 99 | false 100 | false 101 | false 102 | false 103 | 104 | false 105 | false 106 | main 107 | true 108 | false 109 | false 110 | false 111 | false 112 | 113 | 114 | 115 | 116 | 117 | LANG 118 | en_US.UTF-8 119 | 120 | 121 | 122 | $(TargetPath) 123 | 2000 124 | 125 | 126 | false 127 | Local 128 | false 129 | false 130 | Auto 131 | true 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | Default 144 | 145 | 146 | 147 | true 148 | 149 | 150 | 151 | 152 | Unknown 153 | 154 | true 155 | 156 | 157 | -------------------------------------------------------------------------------- /MyActor/MyActor_linux.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {9573870F-13B0-421C-B6B0-9665B02E8508} 23 | 24 | 25 | 26 | Makefile 27 | true 28 | v120 29 | 30 | 31 | Makefile 32 | true 33 | v120 34 | 35 | 36 | Makefile 37 | false 38 | v120 39 | 40 | 41 | Makefile 42 | false 43 | v120 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | $(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0004\4.9.3;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0004\4.9.3\x86_64-pc-linux-gnu;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0004\4.9.3\backward;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0005\include;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0006\include-fixed;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0007\include;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0003\include;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0000\include;$(NMakeIncludeSearchPath) 63 | $(ProjectDir)\gcc_Debug.h;$(VISUALGDB_DIR)\gcc_compat.h;$(NMakeForcedIncludes) 64 | "$(VISUALGDB_DIR)\VisualGDB.exe" /build "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 65 | "$(VISUALGDB_DIR)\VisualGDB.exe" /clean "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 66 | "$(VISUALGDB_DIR)\VisualGDB.exe" /rebuild "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 67 | $(ProjectDir)MyActor_linux-Debug.vgdbsettings 68 | 69 | 70 | 71 | __VisualGDB_CFG_Debug;$(NMakePreprocessorDefinitions) 72 | 73 | 74 | $(NMakeIncludeSearchPath) 75 | $(ProjectDir)\gcc_Debug.h;$(VISUALGDB_DIR)\gcc_compat.h;$(NMakeForcedIncludes) 76 | "$(VISUALGDB_DIR)\VisualGDB.exe" /build "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 77 | "$(VISUALGDB_DIR)\VisualGDB.exe" /clean "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 78 | "$(VISUALGDB_DIR)\VisualGDB.exe" /rebuild "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 79 | $(ProjectDir)MyActor_linux-Debug.vgdbsettings 80 | 81 | 82 | 83 | __VisualGDB_CFG_Debug;$(NMakePreprocessorDefinitions) 84 | 85 | 86 | $(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0008\boost;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0004\4.9.3;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0004\4.9.3\x86_64-pc-linux-gnu;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0004\4.9.3\backward;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0005\include;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0006\include-fixed;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0007\include;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0003\include;$(LOCALAPPDATA)\VisualGDB\RemoteSourceCache\127.0.0.1\0000\include;$(NMakeIncludeSearchPath) 87 | $(ProjectDir)\gcc_Release.h;$(VISUALGDB_DIR)\gcc_compat.h;$(NMakeForcedIncludes) 88 | "$(VISUALGDB_DIR)\VisualGDB.exe" /build "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 89 | "$(VISUALGDB_DIR)\VisualGDB.exe" /clean "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 90 | "$(VISUALGDB_DIR)\VisualGDB.exe" /rebuild "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 91 | $(ProjectDir)MyActor_linux-Release.vgdbsettings 92 | 93 | 94 | 95 | __VisualGDB_CFG_Release;$(NMakePreprocessorDefinitions) 96 | 97 | 98 | $(NMakeIncludeSearchPath) 99 | $(ProjectDir)\gcc_Release.h;$(VISUALGDB_DIR)\gcc_compat.h;$(NMakeForcedIncludes) 100 | __VisualGDB_CFG_Release;$(NMakePreprocessorDefinitions) 101 | "$(VISUALGDB_DIR)\VisualGDB.exe" /build "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 102 | "$(VISUALGDB_DIR)\VisualGDB.exe" /clean "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 103 | "$(VISUALGDB_DIR)\VisualGDB.exe" /rebuild "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 104 | $(ProjectDir)MyActor_linux-Release.vgdbsettings 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /MyActor/MyActor_linux.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {6ab983b4-f062-45d9-8bb7-940c88c7da01} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {fd91e7bd-a988-43ce-84ae-a3686928bc6a} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {40388d9f-3da4-4bdf-8346-e04b5d8c1aa5} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | {75b51378-3840-4c0d-8f2e-c4e6c132469f} 18 | *.mak 19 | 20 | 21 | 22 | 23 | Source files 24 | 25 | 26 | Source files 27 | 28 | 29 | 30 | 31 | 32 | Make files 33 | 34 | 35 | Make files 36 | 37 | 38 | -------------------------------------------------------------------------------- /MyActor/MyActor_linux.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | WindowsLocalDebugger 7 | 8 | 9 | 10 | WindowsLocalDebugger 11 | 12 | -------------------------------------------------------------------------------- /MyActor/MyActor_win.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {662c9093-1bf6-4855-8e21-70dcb5e5eb82} 18 | 19 | 20 | {69308202-1fa8-4703-926d-1b52333d1cd1} 21 | 22 | 23 | 24 | 25 | 源文件 26 | 27 | 28 | 源文件\actor 29 | 30 | 31 | 源文件\actor 32 | 33 | 34 | 源文件\actor 35 | 36 | 37 | 源文件\actor 38 | 39 | 40 | 源文件\actor 41 | 42 | 43 | 源文件\actor 44 | 45 | 46 | 源文件\actor 47 | 48 | 49 | 源文件\actor 50 | 51 | 52 | 源文件\actor 53 | 54 | 55 | 源文件 56 | 57 | 58 | 源文件\actor 59 | 60 | 61 | 源文件\actor 62 | 63 | 64 | 源文件\actor 65 | 66 | 67 | 源文件\actor 68 | 69 | 70 | 源文件\actor 71 | 72 | 73 | 源文件\actor 74 | 75 | 76 | 源文件\actor 77 | 78 | 79 | 源文件\actor 80 | 81 | 82 | 源文件\actor 83 | 84 | 85 | 源文件\actor 86 | 87 | 88 | 89 | 90 | 头文件\actor 91 | 92 | 93 | 头文件\actor 94 | 95 | 96 | 头文件\actor 97 | 98 | 99 | 头文件\actor 100 | 101 | 102 | 头文件\actor 103 | 104 | 105 | 头文件\actor 106 | 107 | 108 | 头文件\actor 109 | 110 | 111 | 头文件\actor 112 | 113 | 114 | 头文件\actor 115 | 116 | 117 | 头文件\actor 118 | 119 | 120 | 头文件\actor 121 | 122 | 123 | 头文件\actor 124 | 125 | 126 | 头文件\actor 127 | 128 | 129 | 头文件\actor 130 | 131 | 132 | 头文件\actor 133 | 134 | 135 | 头文件\actor 136 | 137 | 138 | 头文件\actor 139 | 140 | 141 | 头文件\actor 142 | 143 | 144 | 头文件\actor 145 | 146 | 147 | 头文件\actor 148 | 149 | 150 | 头文件\actor 151 | 152 | 153 | 头文件\actor 154 | 155 | 156 | 头文件\actor 157 | 158 | 159 | 头文件\actor 160 | 161 | 162 | 头文件\actor 163 | 164 | 165 | 头文件\actor 166 | 167 | 168 | 头文件\actor 169 | 170 | 171 | 头文件\actor 172 | 173 | 174 | 头文件\actor 175 | 176 | 177 | 头文件\actor 178 | 179 | 180 | 头文件\actor 181 | 182 | 183 | 头文件\actor 184 | 185 | 186 | 头文件\actor 187 | 188 | 189 | 头文件\actor 190 | 191 | 192 | -------------------------------------------------------------------------------- /MyActor/MyActor_win.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ..\debug\ 5 | WindowsLocalDebugger 6 | 7 | 8 | ..\x64\debug\ 9 | WindowsLocalDebugger 10 | 11 | 12 | ..\release\ 13 | WindowsLocalDebugger 14 | 15 | 16 | ..\x64\release\ 17 | WindowsLocalDebugger 18 | 19 | -------------------------------------------------------------------------------- /MyActor/actor.cpp: -------------------------------------------------------------------------------- 1 | #include "actor/actor_cpp.h" -------------------------------------------------------------------------------- /MyActor/actor/actor_cpp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/actor_cpp.h -------------------------------------------------------------------------------- /MyActor/actor/actor_mutex.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/actor_mutex.h -------------------------------------------------------------------------------- /MyActor/actor/actor_socket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/actor_socket.h -------------------------------------------------------------------------------- /MyActor/actor/actor_timer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/actor_timer.cpp -------------------------------------------------------------------------------- /MyActor/actor/actor_timer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/actor_timer.h -------------------------------------------------------------------------------- /MyActor/actor/async_timer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/async_timer.cpp -------------------------------------------------------------------------------- /MyActor/actor/async_timer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/async_timer.h -------------------------------------------------------------------------------- /MyActor/actor/bind_node_run.cpp: -------------------------------------------------------------------------------- 1 | #include "bind_node_run.h" 2 | 3 | #ifdef ENABLE_UV_ACTOR 4 | 5 | cpp_call_js::cpp_call_js() 6 | { 7 | } 8 | 9 | cpp_call_js::cpp_call_js(v8::Isolate* isolate, const shared_uv_strand& uvStrand, v8::Local callback, v8::Local recv) 10 | :_uvStrand(uvStrand), _callback(isolate, v8::Local::Cast(callback)), _recv(isolate, recv) 11 | { 12 | assert(_uvStrand->in_this_ios()); 13 | assert(callback->IsFunction()); 14 | } 15 | 16 | cpp_call_js::cpp_call_js(v8::Isolate* isolate, const shared_uv_strand& uvStrand, const v8::Persistent>& callback, v8::Local recv) 17 | :_uvStrand(uvStrand), _callback(callback), _recv(isolate, recv) 18 | { 19 | assert(_uvStrand->in_this_ios()); 20 | assert(!callback.IsEmpty()); 21 | } 22 | 23 | cpp_call_js::cpp_call_js(v8::Isolate* isolate, const shared_uv_strand& uvStrand, v8::Local object, const char* funcName) 24 | :cpp_call_js(isolate, uvStrand, object->ToObject()->Get(v8::String::NewFromUtf8(isolate, funcName)), object) {} 25 | 26 | cpp_call_js::~cpp_call_js() 27 | { 28 | reset(); 29 | } 30 | 31 | void cpp_call_js::reset() 32 | { 33 | _uvStrand.reset(); 34 | _callback.Reset(); 35 | } 36 | 37 | bool cpp_call_js::empty() const 38 | { 39 | return !_uvStrand; 40 | } 41 | ////////////////////////////////////////////////////////////////////////// 42 | 43 | js_steady_timer* js_steady_timer::_jsTimer = NULL; 44 | 45 | void js_steady_timer::init(v8::Handle exports) 46 | { 47 | NODE_SET_METHOD(exports, "set_timeout", js_steady_timer::set_timeout); 48 | NODE_SET_METHOD(exports, "set_deadline", js_steady_timer::set_deadline); 49 | NODE_SET_METHOD(exports, "set_interval", js_steady_timer::set_interval); 50 | NODE_SET_METHOD(exports, "clear_timer", js_steady_timer::clear_timer); 51 | } 52 | 53 | void js_steady_timer::install(v8::Isolate* isolate, const shared_uv_strand& strand) 54 | { 55 | _jsTimer = new js_steady_timer(); 56 | _jsTimer->_strand = strand.get(); 57 | } 58 | 59 | void js_steady_timer::uninstall() 60 | { 61 | delete _jsTimer; 62 | _jsTimer = NULL; 63 | } 64 | 65 | js_steady_timer::timer_handle* js_steady_timer::timer_handle::make(v8::Local& v8Obj) 66 | { 67 | js_steady_timer::timer_handle* timerHandle = new js_steady_timer::timer_handle(); 68 | timerHandle->Wrap(v8Obj); 69 | return timerHandle; 70 | } 71 | 72 | void js_steady_timer::set_timeout(const v8::FunctionCallbackInfo& args) 73 | { 74 | assert(2 == args.Length()); 75 | uv_strand::hold_stack uh(_jsTimer->_strand); 76 | typedef v8::Persistent> v8_handle_type; 77 | typedef v8::Persistent> v8_callback_type; 78 | v8::Local v8timerHandleTemp = v8::ObjectTemplate::New(); 79 | v8timerHandleTemp->SetInternalFieldCount(1); 80 | v8::Local v8timerHandle = v8timerHandleTemp->NewInstance(); 81 | js_steady_timer::timer_handle* timerHandle = js_steady_timer::timer_handle::make(v8timerHandle); 82 | int ms = v8_local_to_std::cast(args[0]); 83 | _jsTimer->_strand->over_timer()->timeout(ms, timerHandle->_handler, std::bind([](v8_handle_type& v8Handle, v8_callback_type& callback) 84 | { 85 | v8::Isolate* isolate = v8::Isolate::GetCurrent(); 86 | v8::HandleScope scope(isolate); 87 | v8::Local::New(isolate, callback)->Call((v8::Local)isolate->GetCurrentContext()->Global(), 0, NULL); 88 | }, v8_handle_type(args.GetIsolate(), v8timerHandle), v8_callback_type(args.GetIsolate(), v8::Local::Cast(args[1])))); 89 | args.GetReturnValue().Set(v8timerHandle); 90 | } 91 | 92 | void js_steady_timer::set_deadline(const v8::FunctionCallbackInfo& args) 93 | { 94 | assert(2 == args.Length()); 95 | uv_strand::hold_stack uh(_jsTimer->_strand); 96 | typedef v8::Persistent> v8_handle_type; 97 | typedef v8::Persistent> v8_callback_type; 98 | v8::Local v8timerHandleTemp = v8::ObjectTemplate::New(); 99 | v8timerHandleTemp->SetInternalFieldCount(1); 100 | v8::Local v8timerHandle = v8timerHandleTemp->NewInstance(); 101 | js_steady_timer::timer_handle* timerHandle = js_steady_timer::timer_handle::make(v8timerHandle); 102 | int ms = v8_local_to_std::cast(args[0]); 103 | _jsTimer->_strand->over_timer()->deadline((long long)ms * 1000, timerHandle->_handler, std::bind([](v8_handle_type& v8Handle, v8_callback_type& callback) 104 | { 105 | v8::Isolate* isolate = v8::Isolate::GetCurrent(); 106 | v8::HandleScope scope(isolate); 107 | v8::Local::New(isolate, callback)->Call((v8::Local)isolate->GetCurrentContext()->Global(), 0, NULL); 108 | }, v8_handle_type(args.GetIsolate(), v8timerHandle), v8_callback_type(args.GetIsolate(), v8::Local::Cast(args[1])))); 109 | args.GetReturnValue().Set(v8timerHandle); 110 | } 111 | 112 | void js_steady_timer::set_interval(const v8::FunctionCallbackInfo& args) 113 | { 114 | assert(2 == args.Length()); 115 | uv_strand::hold_stack uh(_jsTimer->_strand); 116 | typedef v8::Persistent> v8_handle_type; 117 | typedef v8::Persistent> v8_callback_type; 118 | v8::Local v8timerHandleTemp = v8::ObjectTemplate::New(); 119 | v8timerHandleTemp->SetInternalFieldCount(1); 120 | v8::Local v8timerHandle = v8timerHandleTemp->NewInstance(); 121 | js_steady_timer::timer_handle* timerHandle = js_steady_timer::timer_handle::make(v8timerHandle); 122 | int ms = v8_local_to_std::cast(args[0]); 123 | _jsTimer->_strand->over_timer()->interval(ms, timerHandle->_handler, std::bind([](v8_handle_type& v8Handle, v8_callback_type& callback) 124 | { 125 | v8::Isolate* isolate = v8::Isolate::GetCurrent(); 126 | v8::HandleScope scope(isolate); 127 | v8::Local::New(isolate, callback)->Call((v8::Local)isolate->GetCurrentContext()->Global(), 0, NULL); 128 | }, v8_handle_type(args.GetIsolate(), v8timerHandle), v8_callback_type(args.GetIsolate(), v8::Local::Cast(args[1])))); 129 | args.GetReturnValue().Set(v8timerHandle); 130 | } 131 | 132 | void js_steady_timer::clear_timer(const v8::FunctionCallbackInfo& args) 133 | { 134 | assert(1 == args.Length()); 135 | uv_strand::hold_stack uh(_jsTimer->_strand); 136 | _jsTimer->_strand->over_timer()->cancel(node::ObjectWrap::Unwrap(v8::Local::Cast(args[0]))->_handler); 137 | } 138 | ////////////////////////////////////////////////////////////////////////// 139 | 140 | v8::Persistent> js_global::_global; 141 | cpp_call_js js_global::global; 142 | 143 | void js_global::install(v8::Isolate* isolate, const shared_uv_strand& strand) 144 | { 145 | if (!_global.IsEmpty()) 146 | { 147 | global = cpp_call_js(isolate, strand, _global); 148 | } 149 | } 150 | 151 | void js_global::uninstall() 152 | { 153 | global.reset(); 154 | _global.Reset(); 155 | } 156 | 157 | #endif -------------------------------------------------------------------------------- /MyActor/actor/bind_node_run.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/bind_node_run.h -------------------------------------------------------------------------------- /MyActor/actor/bind_qt_run.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/bind_qt_run.cpp -------------------------------------------------------------------------------- /MyActor/actor/bind_qt_run.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/bind_qt_run.h -------------------------------------------------------------------------------- /MyActor/actor/channel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/channel.h -------------------------------------------------------------------------------- /MyActor/actor/check_actor_stack.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/check_actor_stack.h -------------------------------------------------------------------------------- /MyActor/actor/context_pool.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/context_pool.cpp -------------------------------------------------------------------------------- /MyActor/actor/context_pool.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/context_pool.h -------------------------------------------------------------------------------- /MyActor/actor/context_yield.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/context_yield.cpp -------------------------------------------------------------------------------- /MyActor/actor/context_yield.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONTEXT_YIELD_H 2 | #define __CONTEXT_YIELD_H 3 | #include 4 | 5 | namespace context_yield 6 | { 7 | struct context_info 8 | { 9 | void* obj = 0; 10 | void* stackTop = 0; 11 | void* nc = 0; 12 | size_t stackSize = 0; 13 | size_t reserveSize = 0; 14 | }; 15 | 16 | bool is_thread_a_fiber(); 17 | bool convert_thread_to_fiber(); 18 | bool convert_fiber_to_thread(); 19 | typedef void(*context_handler)(context_info* info, void* p); 20 | context_info* make_context(size_t stackSize, context_handler handler, void* p); 21 | void push_yield(context_info* info); 22 | void pull_yield(context_info* info); 23 | void delete_context(context_info* info); 24 | void decommit_context(context_info* info); 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /MyActor/actor/generator.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/generator.h -------------------------------------------------------------------------------- /MyActor/actor/io_engine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/io_engine.h -------------------------------------------------------------------------------- /MyActor/actor/lambda_ref.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/lambda_ref.h -------------------------------------------------------------------------------- /MyActor/actor/lib/fcontext_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/lib/fcontext_x64.lib -------------------------------------------------------------------------------- /MyActor/actor/lib/fcontext_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/lib/fcontext_x86.lib -------------------------------------------------------------------------------- /MyActor/actor/lib/libfcontext_aarch64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/lib/libfcontext_aarch64.a -------------------------------------------------------------------------------- /MyActor/actor/lib/libfcontext_armhf32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/lib/libfcontext_armhf32.a -------------------------------------------------------------------------------- /MyActor/actor/lib/libfcontext_armsf32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/lib/libfcontext_armsf32.a -------------------------------------------------------------------------------- /MyActor/actor/lib/libfcontext_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/lib/libfcontext_x64.a -------------------------------------------------------------------------------- /MyActor/actor/lib/libfcontext_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/lib/libfcontext_x86.a -------------------------------------------------------------------------------- /MyActor/actor/my_actor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/my_actor.cpp -------------------------------------------------------------------------------- /MyActor/actor/my_actor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/my_actor.h -------------------------------------------------------------------------------- /MyActor/actor/qt_strand.cpp: -------------------------------------------------------------------------------- 1 | #include "qt_strand.h" 2 | #include "bind_qt_run.h" 3 | 4 | #ifdef ENABLE_QT_ACTOR 5 | qt_strand::qt_strand() 6 | { 7 | _ui = NULL; 8 | #if (ENABLE_QT_ACTOR && ENABLE_UV_ACTOR) 9 | _strandChoose = boost_strand::strand_ui; 10 | #endif 11 | } 12 | 13 | qt_strand::~qt_strand() 14 | { 15 | assert(!_ui); 16 | } 17 | 18 | shared_qt_strand qt_strand::create(io_engine& ioEngine, bind_qt_run_base* ui) 19 | { 20 | shared_qt_strand res = std::make_shared(); 21 | res->_ioEngine = &ioEngine; 22 | res->_ui = ui; 23 | res->_actorTimer = new ActorTimer_(res); 24 | res->_overTimer = new overlap_timer(res); 25 | res->_weakThis = res; 26 | return res; 27 | } 28 | 29 | void qt_strand::release() 30 | { 31 | assert(in_this_ios()); 32 | _ui = NULL; 33 | } 34 | 35 | bool qt_strand::released() 36 | { 37 | assert(in_this_ios()); 38 | return !_ui; 39 | } 40 | 41 | shared_strand qt_strand::clone() 42 | { 43 | assert(_ui); 44 | return create(*_ioEngine, _ui); 45 | } 46 | 47 | bool qt_strand::in_this_ios() 48 | { 49 | assert(_ui); 50 | return _ui->running_in_ui_thread(); 51 | } 52 | 53 | bool qt_strand::running_in_this_thread() 54 | { 55 | assert(_ui); 56 | return _ui->running_in_this_thread(); 57 | } 58 | 59 | bool qt_strand::sync_safe() 60 | { 61 | return true; 62 | } 63 | 64 | bool qt_strand::is_running() 65 | { 66 | return true; 67 | } 68 | 69 | bool qt_strand::only_self() 70 | { 71 | assert(_ui); 72 | return _ui->only_self(); 73 | } 74 | 75 | bind_qt_run_base* qt_strand::self_ui() 76 | { 77 | return _ui; 78 | } 79 | #endif -------------------------------------------------------------------------------- /MyActor/actor/qt_strand.h: -------------------------------------------------------------------------------- 1 | #ifndef __QT_STRAND_H 2 | #define __QT_STRAND_H 3 | 4 | #include "shared_strand.h" 5 | 6 | #ifdef ENABLE_QT_ACTOR 7 | class bind_qt_run_base; 8 | class qt_strand; 9 | typedef std::shared_ptr shared_qt_strand; 10 | 11 | class qt_strand : public boost_strand 12 | { 13 | friend boost_strand; 14 | friend bind_qt_run_base; 15 | FRIEND_SHARED_PTR(qt_strand); 16 | private: 17 | qt_strand(); 18 | ~qt_strand(); 19 | public: 20 | static shared_qt_strand create(io_engine& ioEngine, bind_qt_run_base* ui); 21 | private: 22 | void release(); 23 | bool released(); 24 | shared_strand clone(); 25 | bool in_this_ios(); 26 | bool running_in_this_thread(); 27 | bool sync_safe(); 28 | bool is_running(); 29 | bool only_self(); 30 | bind_qt_run_base* self_ui(); 31 | template 32 | void _dispatch_ui(Handler&& handler); 33 | template 34 | void _post_ui(Handler&& handler); 35 | private: 36 | bind_qt_run_base* _ui; 37 | }; 38 | #endif 39 | 40 | #endif -------------------------------------------------------------------------------- /MyActor/actor/run_strand.h: -------------------------------------------------------------------------------- 1 | #ifndef __RUN_STRAND_H 2 | #define __RUN_STRAND_H 3 | 4 | #include "qt_strand.h" 5 | #include "uv_strand.h" 6 | 7 | #ifdef ENABLE_QT_ACTOR 8 | 9 | template 10 | void boost_strand::post_ui(Handler&& handler) 11 | { 12 | static_cast(this)->_post_ui(std::forward(handler)); 13 | } 14 | 15 | template 16 | void boost_strand::dispatch_ui(Handler&& handler) 17 | { 18 | static_cast(this)->_dispatch_ui(std::forward(handler)); 19 | } 20 | 21 | #endif 22 | 23 | #ifdef ENABLE_UV_ACTOR 24 | 25 | template 26 | void boost_strand::post_uv(Handler&& handler) 27 | { 28 | static_cast(this)->_post_uv(std::forward(handler)); 29 | } 30 | 31 | template 32 | void boost_strand::dispatch_uv(Handler&& handler) 33 | { 34 | static_cast(this)->_dispatch_uv(std::forward(handler)); 35 | } 36 | 37 | #endif 38 | 39 | #endif -------------------------------------------------------------------------------- /MyActor/actor/run_thread.cpp: -------------------------------------------------------------------------------- 1 | #include "run_thread.h" 2 | 3 | #ifdef _WIN32 4 | run_thread::run_thread() 5 | { 6 | _handle = NULL; 7 | _threadID = 0; 8 | } 9 | 10 | run_thread::~run_thread() 11 | { 12 | assert(!_handle); 13 | } 14 | 15 | DWORD WINAPI run_thread::thread_exec(LPVOID p) 16 | { 17 | as_ptype(p)->invoke(); 18 | return 0; 19 | } 20 | 21 | void run_thread::join() 22 | { 23 | assert(this_thread_id() != get_id()); 24 | if (_handle) 25 | { 26 | WaitForSingleObject(_handle, INFINITE); 27 | CloseHandle(_handle); 28 | _handle = NULL; 29 | _threadID = 0; 30 | } 31 | } 32 | 33 | run_thread::thread_id run_thread::get_id() 34 | { 35 | thread_id r; 36 | r._id = _threadID; 37 | return r; 38 | } 39 | 40 | run_thread::thread_id run_thread::this_thread_id() 41 | { 42 | thread_id r; 43 | r._id = GetCurrentThreadId(); 44 | return r; 45 | } 46 | 47 | void run_thread::swap(run_thread& s) 48 | { 49 | if (this != &s) 50 | { 51 | std::swap(_handle, s._handle); 52 | std::swap(_threadID, s._threadID); 53 | } 54 | } 55 | 56 | void run_thread::set_current_thread_name(const char* name) 57 | { 58 | //https://msdn.microsoft.com/en-us/library/xcb2z8hs(v=VS.71).aspx 59 | struct 60 | { 61 | DWORD dwType; // must be 0x1000 62 | LPCSTR szName; // pointer to name (in user addr space) 63 | DWORD dwThreadID; // thread ID (-1=caller thread) 64 | DWORD dwFlags; // reserved for future use, must be zero 65 | } info = { 0x1000, name, GetCurrentThreadId(), 0 }; 66 | #ifdef _MSC_VER 67 | __try { RaiseException(0x406D1388, 0, sizeof(info) / sizeof(DWORD), (ULONG_PTR*)&info); } 68 | __except (EXCEPTION_EXECUTE_HANDLER) {} 69 | #elif (__GNUG__ && ENABLE_GCC_SEH) 70 | __seh_try { RaiseException(0x406D1388, 0, sizeof(info) / sizeof(DWORD), (ULONG_PTR*)&info); } 71 | __seh_except(EXCEPTION_EXECUTE_HANDLER) {} 72 | __seh_end_except 73 | #endif 74 | } 75 | 76 | size_t run_thread::cpu_core_number() 77 | { 78 | DWORD size = 0; 79 | 80 | GetLogicalProcessorInformation(NULL, &size); 81 | if (ERROR_INSUFFICIENT_BUFFER != GetLastError()) 82 | { 83 | return 0; 84 | } 85 | 86 | const size_t Elements = size / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); 87 | std::vector buffer(Elements); 88 | if (GetLogicalProcessorInformation(&buffer.front(), &size) == FALSE) 89 | { 90 | return 0; 91 | } 92 | 93 | size_t cores = 0; 94 | for (size_t i = 0; i < Elements; ++i) 95 | { 96 | if (buffer[i].Relationship == RelationProcessorCore) 97 | { 98 | cores++; 99 | } 100 | } 101 | return cores; 102 | } 103 | 104 | size_t run_thread::cpu_thread_number() 105 | { 106 | SYSTEM_INFO info; 107 | GetSystemInfo(&info); 108 | return (size_t)info.dwNumberOfProcessors; 109 | } 110 | 111 | void run_thread::sleep(int ms) 112 | { 113 | Sleep(ms); 114 | } 115 | 116 | bool run_thread::set_affinity(int i) 117 | { 118 | return mask_affinity((unsigned long long)1 << i); 119 | } 120 | 121 | bool run_thread::mask_affinity(unsigned long long mask) 122 | { 123 | assert(_handle); 124 | assert(mask && 0 == (mask & (mask - 1))); 125 | return 0 != SetThreadAffinityMask(_handle, (DWORD_PTR)mask); 126 | } 127 | 128 | bool run_thread::set_ideal(int i) 129 | { 130 | assert(_handle); 131 | assert(0 <= i); 132 | return (DWORD)-1 != SetThreadIdealProcessor(_handle, (DWORD)i); 133 | } 134 | ////////////////////////////////////////////////////////////////////////// 135 | 136 | tls_space::tls_space() 137 | { 138 | _index = TlsAlloc(); 139 | } 140 | 141 | tls_space::~tls_space() 142 | { 143 | TlsFree(_index); 144 | } 145 | 146 | void tls_space::set_space(void** val) 147 | { 148 | TlsSetValue(_index, (LPVOID)val); 149 | } 150 | 151 | void** tls_space::get_space() 152 | { 153 | return (void**)TlsGetValue(_index); 154 | } 155 | #elif __linux__ 156 | 157 | #include 158 | #include 159 | #include 160 | #include 161 | #include 162 | 163 | run_thread::run_thread() 164 | { 165 | _pthread = 0; 166 | } 167 | 168 | run_thread::~run_thread() 169 | { 170 | assert(!_pthread); 171 | } 172 | 173 | void* run_thread::thread_exec(void* p) 174 | { 175 | as_ptype(p)->invoke(); 176 | return NULL; 177 | } 178 | 179 | void run_thread::join() 180 | { 181 | assert(this_thread_id() != get_id()); 182 | if (_pthread) 183 | { 184 | pthread_join(_pthread, NULL); 185 | _pthread = 0; 186 | } 187 | } 188 | 189 | run_thread::thread_id run_thread::get_id() 190 | { 191 | thread_id r; 192 | r._id = _pthread; 193 | return r; 194 | } 195 | 196 | run_thread::thread_id run_thread::this_thread_id() 197 | { 198 | thread_id r; 199 | r._id = pthread_self(); 200 | return r; 201 | } 202 | 203 | void run_thread::swap(run_thread& s) 204 | { 205 | if (this != &s) 206 | { 207 | std::swap(_pthread, s._pthread); 208 | } 209 | } 210 | 211 | void run_thread::set_current_thread_name(const char* name) 212 | { 213 | prctl(PR_SET_NAME, name); 214 | } 215 | 216 | size_t run_thread::cpu_core_number() 217 | { 218 | try 219 | { 220 | std::ifstream proc_cpuinfo ("/proc/cpuinfo"); 221 | const std::string physical_id("physical id"); 222 | const std::string core_id("core id"); 223 | size_t cores = 0; 224 | std::string line; 225 | while (getline(proc_cpuinfo, line)) 226 | { 227 | if (!line.empty()) 228 | { 229 | const size_t i = line.find(':'); 230 | if (i >= line.size()) 231 | { 232 | return sysconf(_SC_NPROCESSORS_CONF); 233 | } 234 | if (i >= core_id.size()) 235 | { 236 | const size_t j = line.find(core_id); 237 | if (j < line.size()) 238 | { 239 | size_t k = 0; 240 | for (; k < j; k++) 241 | { 242 | if ('\t' != line[k] && ' ' != line[k]) 243 | { 244 | break; 245 | } 246 | } 247 | if (k == j) 248 | { 249 | for (k += core_id.size(); k < i; k++) 250 | { 251 | if ('\t' != line[k] && ' ' != line[k]) 252 | { 253 | break; 254 | } 255 | } 256 | if (k == i) 257 | { 258 | cores++; 259 | } 260 | } 261 | } 262 | } 263 | } 264 | } 265 | return 0 != cores ? cores : sysconf(_SC_NPROCESSORS_CONF); 266 | } 267 | catch (...) 268 | { 269 | return sysconf(_SC_NPROCESSORS_CONF); 270 | } 271 | } 272 | 273 | size_t run_thread::cpu_thread_number() 274 | { 275 | return (size_t)sysconf(_SC_NPROCESSORS_ONLN); 276 | } 277 | 278 | void run_thread::sleep(int ms) 279 | { 280 | if (ms) 281 | { 282 | usleep((__useconds_t)ms * 1000); 283 | } 284 | else 285 | { 286 | sched_yield(); 287 | } 288 | } 289 | 290 | bool run_thread::set_affinity(int i) 291 | { 292 | return mask_affinity((unsigned long long)1 << i); 293 | } 294 | 295 | bool run_thread::mask_affinity(unsigned long long mask) 296 | { 297 | assert(_pthread); 298 | assert(mask && 0 == (mask & (mask - 1))); 299 | cpu_set_t cpumask; 300 | if (0 == pthread_getaffinity_np(_pthread, sizeof(cpumask), &cpumask)) 301 | { 302 | for (size_t i = 0; i < fixed_array_length(cpumask.__bits); i++) 303 | { 304 | if (cpumask.__bits[i]) 305 | { 306 | CPU_ZERO(&cpumask); 307 | cpumask.__bits[i] = (__cpu_mask)mask; 308 | return 0 == pthread_setaffinity_np(_pthread, sizeof(cpumask), &cpumask); 309 | } 310 | } 311 | } 312 | return false; 313 | } 314 | 315 | bool run_thread::set_ideal(int i) 316 | { 317 | assert(_pthread); 318 | cpu_set_t cpumask; 319 | assert(0 <= i && fixed_array_length(cpumask.__bits) > (size_t)i); 320 | CPU_ZERO(&cpumask); 321 | cpumask.__bits[i] = 255; 322 | return 0 == pthread_setaffinity_np(_pthread, sizeof(cpumask), &cpumask); 323 | } 324 | ////////////////////////////////////////////////////////////////////////// 325 | 326 | tls_space::tls_space() 327 | { 328 | pthread_key_create(&_key, NULL); 329 | } 330 | 331 | tls_space::~tls_space() 332 | { 333 | pthread_key_delete(_key); 334 | } 335 | 336 | void tls_space::set_space(void** val) 337 | { 338 | pthread_setspecific(_key, val); 339 | } 340 | 341 | void** tls_space::get_space() 342 | { 343 | return (void**)pthread_getspecific(_key); 344 | } 345 | #endif 346 | 347 | bool run_thread::thread_id::operator<(const thread_id& s) const 348 | { 349 | return _id < s._id; 350 | } 351 | 352 | bool run_thread::thread_id::operator>(const thread_id& s) const 353 | { 354 | return _id > s._id; 355 | } 356 | 357 | bool run_thread::thread_id::operator<=(const thread_id& s) const 358 | { 359 | return _id <= s._id; 360 | } 361 | 362 | bool run_thread::thread_id::operator>=(const thread_id& s) const 363 | { 364 | return _id >= s._id; 365 | } 366 | bool run_thread::thread_id::operator==(const thread_id& s) const 367 | { 368 | return _id == s._id; 369 | } 370 | 371 | bool run_thread::thread_id::operator!=(const thread_id& s) const 372 | { 373 | return _id != s._id; 374 | } -------------------------------------------------------------------------------- /MyActor/actor/run_thread.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/run_thread.h -------------------------------------------------------------------------------- /MyActor/actor/scattered.cpp: -------------------------------------------------------------------------------- 1 | #include "scattered.h" 2 | #include "run_thread.h" 3 | #include 4 | #ifdef WIN32 5 | #include 6 | #include 7 | #include 8 | #endif 9 | #include 10 | #include 11 | 12 | #ifdef WIN32 13 | #ifdef _MSC_VER 14 | #pragma comment(lib, "Winmm.lib") 15 | #endif 16 | 17 | struct pc_cycle 18 | { 19 | pc_cycle() 20 | { 21 | LARGE_INTEGER frep; 22 | if (!QueryPerformanceFrequency(&frep)) 23 | { 24 | _sCycle = 0; 25 | _msCycle = 0; 26 | _usCycle = 0; 27 | assert(false); 28 | return; 29 | } 30 | _sCycle = 1.0 / (double)frep.QuadPart; 31 | _msCycle = 1000.0 / (double)frep.QuadPart; 32 | _usCycle = 1000000.0 / (double)frep.QuadPart; 33 | } 34 | 35 | double _sCycle; 36 | double _msCycle; 37 | double _usCycle; 38 | } _pcCycle; 39 | #endif 40 | 41 | void move_test::operator=(move_test&& s) 42 | { 43 | _generation = s._generation + 1; 44 | _count = std::move(s._count); 45 | if (_count) 46 | { 47 | _count->_moveCount++; 48 | if (_count->_cb) 49 | { 50 | _count->_cb(_count); 51 | } 52 | } 53 | } 54 | 55 | void move_test::operator=(const move_test& s) 56 | { 57 | _generation = s._generation + 1; 58 | _count = s._count; 59 | if (_count) 60 | { 61 | _count->_copyCount++; 62 | if (_count->_cb) 63 | { 64 | _count->_cb(_count); 65 | } 66 | } 67 | } 68 | 69 | std::ostream& operator <<(std::ostream& out, const move_test& s) 70 | { 71 | if (s._count) 72 | { 73 | out << "(id:" << s._count->_id << ", generation:" << s._generation << ", move:" << s._count->_moveCount << ", copy:" << s._count->_copyCount << ")"; 74 | } 75 | else 76 | { 77 | out << "(id:null, generation:null, move:null, copy:null)"; 78 | } 79 | return out; 80 | } 81 | 82 | std::wostream& operator <<(std::wostream& out, const move_test& s) 83 | { 84 | if (s._count) 85 | { 86 | out << L"(id:" << s._count->_id << L", generation:" << s._generation << L", move:" << s._count->_moveCount << L", copy:" << s._count->_copyCount << L")"; 87 | } 88 | else 89 | { 90 | out << L"(id:null, generation:null, move:null, copy:null)"; 91 | } 92 | return out; 93 | } 94 | 95 | void move_test::reset() 96 | { 97 | _count.reset(); 98 | } 99 | 100 | move_test::move_test(move_test&& s) 101 | { 102 | *this = std::move(s); 103 | } 104 | 105 | move_test::move_test(const move_test& s) 106 | { 107 | *this = s; 108 | } 109 | 110 | move_test::move_test(int id, const std::function)>& cb) 111 | { 112 | _count = std::make_shared(); 113 | _count->_copyCount = 0; 114 | _count->_moveCount = 0; 115 | _count->_id = id; 116 | _count->_cb = cb; 117 | _generation = 0; 118 | } 119 | 120 | move_test::move_test(int id) 121 | { 122 | _count = std::make_shared(); 123 | _count->_copyCount = 0; 124 | _count->_moveCount = 0; 125 | _count->_id = id; 126 | _generation = 0; 127 | } 128 | 129 | move_test::move_test() 130 | :_generation(0) 131 | { 132 | 133 | } 134 | 135 | move_test::~move_test() 136 | { 137 | 138 | } 139 | ////////////////////////////////////////////////////////////////////////// 140 | 141 | std::string get_time_string_us() 142 | { 143 | auto tm = boost::posix_time::microsec_clock::local_time(); 144 | auto date = tm.date(); 145 | auto time = tm.time_of_day(); 146 | char buff[32]; 147 | snprintf(buff, sizeof(buff), "%u-%02u-%02u %02u:%02u:%02u.%06u", (int)date.year(), (int)date.month(), (int)date.day(), \ 148 | (int)time.hours(), (int)time.minutes(), (int)time.seconds(), (int)time.fractional_seconds()); 149 | return buff; 150 | } 151 | 152 | std::string get_time_string_ms() 153 | { 154 | auto tm = boost::posix_time::microsec_clock::local_time(); 155 | auto date = tm.date(); 156 | auto time = tm.time_of_day(); 157 | char buff[32]; 158 | snprintf(buff, sizeof(buff), "%u-%02u-%02u %02u:%02u:%02u.%03u", (int)date.year(), (int)date.month(), (int)date.day(), \ 159 | (int)time.hours(), (int)time.minutes(), (int)time.seconds(), (int)time.fractional_seconds() / 1000); 160 | return buff; 161 | } 162 | 163 | std::string get_time_string_s() 164 | { 165 | auto tm = boost::posix_time::microsec_clock::local_time(); 166 | auto date = tm.date(); 167 | auto time = tm.time_of_day(); 168 | char buff[32]; 169 | snprintf(buff, sizeof(buff), "%u-%02u-%02u %02u:%02u:%02u", (int)date.year(), (int)date.month(), (int)date.day(), \ 170 | (int)time.hours(), (int)time.minutes(), (int)time.seconds()); 171 | return buff; 172 | } 173 | 174 | std::string get_time_string_file_s() 175 | { 176 | auto tm = boost::posix_time::microsec_clock::local_time(); 177 | auto date = tm.date(); 178 | auto time = tm.time_of_day(); 179 | char buff[32]; 180 | snprintf(buff, sizeof(buff), "%u-%02u-%02u %02u.%02u.%02u", (int)date.year(), (int)date.month(), (int)date.day(), \ 181 | (int)time.hours(), (int)time.minutes(), (int)time.seconds()); 182 | return buff; 183 | } 184 | 185 | void print_time_us() 186 | { 187 | auto tm = boost::posix_time::microsec_clock::local_time(); 188 | auto date = tm.date(); 189 | auto time = tm.time_of_day(); 190 | printf("%u-%02u-%02u %02u:%02u:%02u.%06u", (int)date.year(), (int)date.month(), (int)date.day(), \ 191 | (int)time.hours(), (int)time.minutes(), (int)time.seconds(), (int)time.fractional_seconds()); 192 | } 193 | 194 | void print_time_ms() 195 | { 196 | auto tm = boost::posix_time::microsec_clock::local_time(); 197 | auto date = tm.date(); 198 | auto time = tm.time_of_day(); 199 | printf("%u-%02u-%02u %02u:%02u:%02u.%03u", (int)date.year(), (int)date.month(), (int)date.day(), \ 200 | (int)time.hours(), (int)time.minutes(), (int)time.seconds(), (int)time.fractional_seconds() / 1000); 201 | } 202 | 203 | void print_time_s() 204 | { 205 | auto tm = boost::posix_time::microsec_clock::local_time(); 206 | auto date = tm.date(); 207 | auto time = tm.time_of_day(); 208 | printf("%u-%02u-%02u %02u:%02u:%02u", (int)date.year(), (int)date.month(), (int)date.day(), \ 209 | (int)time.hours(), (int)time.minutes(), (int)time.seconds()); 210 | } 211 | 212 | void print_time_us(std::ostream& out) 213 | { 214 | auto tm = boost::posix_time::microsec_clock::local_time(); 215 | auto date = tm.date(); 216 | auto time = tm.time_of_day(); 217 | char buff[32]; 218 | snprintf(buff, sizeof(buff), "%u-%02u-%02u %02u:%02u:%02u.%06u", (int)date.year(), (int)date.month(), (int)date.day(), \ 219 | (int)time.hours(), (int)time.minutes(), (int)time.seconds(), (int)time.fractional_seconds()); 220 | out << buff; 221 | } 222 | 223 | void print_time_ms(std::ostream& out) 224 | { 225 | auto tm = boost::posix_time::microsec_clock::local_time(); 226 | auto date = tm.date(); 227 | auto time = tm.time_of_day(); 228 | char buff[32]; 229 | snprintf(buff, sizeof(buff), "%u-%02u-%02u %02u:%02u:%02u.%03u", (int)date.year(), (int)date.month(), (int)date.day(), \ 230 | (int)time.hours(), (int)time.minutes(), (int)time.seconds(), (int)time.fractional_seconds() / 1000); 231 | out << buff; 232 | } 233 | 234 | void print_time_s(std::ostream& out) 235 | { 236 | auto tm = boost::posix_time::microsec_clock::local_time(); 237 | auto date = tm.date(); 238 | auto time = tm.time_of_day(); 239 | char buff[32]; 240 | snprintf(buff, sizeof(buff), "%u-%02u-%02u %02u:%02u:%02u", (int)date.year(), (int)date.month(), (int)date.day(), \ 241 | (int)time.hours(), (int)time.minutes(), (int)time.seconds()); 242 | out << buff; 243 | } 244 | 245 | void print_time_us(std::wostream& out) 246 | { 247 | auto tm = boost::posix_time::microsec_clock::local_time(); 248 | auto date = tm.date(); 249 | auto time = tm.time_of_day(); 250 | char buff[32]; 251 | snprintf(buff, sizeof(buff), "%u-%02u-%02u %02u:%02u:%02u.%06u", (int)date.year(), (int)date.month(), (int)date.day(), \ 252 | (int)time.hours(), (int)time.minutes(), (int)time.seconds(), (int)time.fractional_seconds()); 253 | out << buff; 254 | } 255 | 256 | void print_time_ms(std::wostream& out) 257 | { 258 | auto tm = boost::posix_time::microsec_clock::local_time(); 259 | auto date = tm.date(); 260 | auto time = tm.time_of_day(); 261 | char buff[32]; 262 | snprintf(buff, sizeof(buff), "%u-%02u-%02u %02u:%02u:%02u.%03u", (int)date.year(), (int)date.month(), (int)date.day(), \ 263 | (int)time.hours(), (int)time.minutes(), (int)time.seconds(), (int)time.fractional_seconds() / 1000); 264 | out << buff; 265 | } 266 | 267 | void print_time_s(std::wostream& out) 268 | { 269 | auto tm = boost::posix_time::microsec_clock::local_time(); 270 | auto date = tm.date(); 271 | auto time = tm.time_of_day(); 272 | char buff[32]; 273 | snprintf(buff, sizeof(buff), "%u-%02u-%02u %02u:%02u:%02u", (int)date.year(), (int)date.month(), (int)date.day(), \ 274 | (int)time.hours(), (int)time.minutes(), (int)time.seconds()); 275 | out << buff; 276 | } 277 | 278 | #ifdef WIN32 279 | 280 | void enable_high_resolution() 281 | { 282 | typedef LONG(__stdcall * nt_set_timer_resolution)(IN ULONG DesiredTime, IN BOOLEAN SetResolution, OUT PULONG ActualTime); 283 | typedef LONG(__stdcall * nt_query_timer_resolution)(OUT PULONG MaximumTime, OUT PULONG MinimumTime, OUT PULONG CurrentTime); 284 | HMODULE hNtDll = LoadLibrary(TEXT("NtDll.dll")); 285 | if (hNtDll) 286 | { 287 | nt_query_timer_resolution NtQueryTimerResolution = (nt_query_timer_resolution)GetProcAddress(hNtDll, "NtQueryTimerResolution"); 288 | nt_set_timer_resolution NtSetTimerResolution = (nt_set_timer_resolution)GetProcAddress(hNtDll, "NtSetTimerResolution"); 289 | if (NtQueryTimerResolution && NtSetTimerResolution) 290 | { 291 | ULONG MaximumTime = 0; 292 | ULONG MinimumTime = 0; 293 | ULONG CurrentTime = 0; 294 | if (!NtQueryTimerResolution(&MaximumTime, &MinimumTime, &CurrentTime)) 295 | { 296 | ULONG ActualTime = 0; 297 | if (!NtSetTimerResolution(MinimumTime, TRUE, &ActualTime)) 298 | { 299 | FreeLibrary(hNtDll); 300 | return; 301 | } 302 | } 303 | } 304 | FreeLibrary(hNtDll); 305 | } 306 | timeBeginPeriod(1); 307 | } 308 | 309 | long long get_tick_us() 310 | { 311 | LARGE_INTEGER quadPart; 312 | QueryPerformanceCounter(&quadPart); 313 | return (long long)((double)quadPart.QuadPart*_pcCycle._usCycle); 314 | } 315 | 316 | long long get_tick_ms() 317 | { 318 | LARGE_INTEGER quadPart; 319 | QueryPerformanceCounter(&quadPart); 320 | return (long long)((double)quadPart.QuadPart*_pcCycle._msCycle); 321 | } 322 | 323 | int get_tick_s() 324 | { 325 | LARGE_INTEGER quadPart; 326 | QueryPerformanceCounter(&quadPart); 327 | return (int)((double)quadPart.QuadPart*_pcCycle._sCycle); 328 | } 329 | 330 | #elif __linux__ 331 | 332 | void enable_high_resolution() 333 | { 334 | } 335 | 336 | long long get_tick_us() 337 | { 338 | struct timespec ts; 339 | clock_gettime(CLOCK_MONOTONIC, &ts); 340 | return (long long)ts.tv_sec * 1000000 + ts.tv_nsec/1000; 341 | } 342 | 343 | long long get_tick_ms() 344 | { 345 | struct timespec ts; 346 | clock_gettime(CLOCK_MONOTONIC, &ts); 347 | return (long long)ts.tv_sec * 1000 + ts.tv_nsec/1000000; 348 | } 349 | 350 | int get_tick_s() 351 | { 352 | struct timespec ts; 353 | clock_gettime(CLOCK_MONOTONIC, &ts); 354 | return (int)ts.tv_sec; 355 | } 356 | 357 | #endif 358 | 359 | long long rel2abs_tick(int ms) 360 | { 361 | return get_tick_us() + (long long)ms * 1000; 362 | } 363 | 364 | long long rel2abs_tick(long long us) 365 | { 366 | return get_tick_us() + us; 367 | } 368 | 369 | #ifdef __GNUG__ 370 | 371 | void* get_sp() 372 | { 373 | void* result; 374 | #ifdef __x86_64__ 375 | __asm__("movq %%rsp, %0": "=r"(result)); 376 | #elif __i386__ 377 | __asm__("movl %%esp, %0": "=r"(result)); 378 | #elif (_ARM32 || _ARM64) 379 | __asm__("mov %0, %%sp": "=r"(result)); 380 | #endif 381 | return result; 382 | } 383 | 384 | unsigned long long cpu_tick() 385 | { 386 | #if (defined __x86_64__) || (defined __i386__) 387 | unsigned int __a, __d; 388 | __asm__("rdtsc" : "=a" (__a), "=d" (__d)); 389 | return ((unsigned long long)__a) | (((unsigned long long)__d) << 32); 390 | #elif (_ARM32 || _ARM64) 391 | struct timespec ts; 392 | clock_gettime(CLOCK_MONOTONIC, &ts); 393 | return (unsigned long long)ts.tv_sec * 1000000000 + ts.tv_nsec; 394 | #endif 395 | } 396 | #endif -------------------------------------------------------------------------------- /MyActor/actor/scattered.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/scattered.h -------------------------------------------------------------------------------- /MyActor/actor/shared_strand.cpp: -------------------------------------------------------------------------------- 1 | #include "shared_strand.h" 2 | #include "actor_timer.h" 3 | #include "async_timer.h" 4 | 5 | #define NEXT_TICK_SPACE_SIZE (sizeof(void*)*8) 6 | 7 | boost_strand::boost_strand() 8 | :_ioEngine(NULL), _strand(NULL), _actorTimer(NULL) 9 | #ifdef ENABLE_NEXT_TICK 10 | ,_thisRoundCount(0) 11 | ,_reuMemAlloc(NULL) 12 | #endif //ENABLE_NEXT_TICK 13 | #if (ENABLE_QT_ACTOR && ENABLE_UV_ACTOR) 14 | ,_strandChoose(strand_default) 15 | #endif 16 | { 17 | #ifdef ENABLE_NEXT_TICK 18 | _nextTickAlloc[0] = NULL; 19 | _nextTickAlloc[1] = NULL; 20 | _nextTickAlloc[2] = NULL; 21 | #endif 22 | } 23 | 24 | boost_strand::~boost_strand() 25 | { 26 | #ifdef ENABLE_NEXT_TICK 27 | assert(_frontTickQueue.empty()); 28 | assert(_backTickQueue.empty()); 29 | assert(!_strand || (ready_empty() && waiting_empty())); 30 | delete _nextTickAlloc[0]; 31 | delete _nextTickAlloc[1]; 32 | delete _nextTickAlloc[2]; 33 | delete _reuMemAlloc; 34 | #endif //ENABLE_NEXT_TICK 35 | delete _actorTimer; 36 | delete _overTimer; 37 | delete _strand; 38 | } 39 | 40 | shared_strand boost_strand::create(io_engine& ioEngine) 41 | { 42 | shared_strand res = ioEngine._strandPool->pick(); 43 | res->_weakThis = res; 44 | if (!res->_ioEngine) 45 | { 46 | res->_ioEngine = &ioEngine; 47 | res->_strand = new strand_type(ioEngine); 48 | #ifdef ENABLE_NEXT_TICK 49 | res->_reuMemAlloc = new reusable_mem(); 50 | res->_nextTickAlloc[0] = new mem_alloc2(ioEngine._poolSize); 51 | res->_nextTickAlloc[1] = new mem_alloc2(ioEngine._poolSize / 2); 52 | res->_nextTickAlloc[2] = new mem_alloc2(ioEngine._poolSize / 4); 53 | #endif 54 | res->_actorTimer = new ActorTimer_(res); 55 | res->_overTimer = new overlap_timer(res); 56 | } 57 | return res; 58 | } 59 | 60 | std::vector boost_strand::create_multi(size_t n, io_engine& ioEngine) 61 | { 62 | assert(0 != n); 63 | std::vector res(n); 64 | for (size_t i = 0; i < n; i++) 65 | { 66 | res[i] = boost_strand::create(ioEngine); 67 | } 68 | return res; 69 | } 70 | 71 | void boost_strand::create_multi(shared_strand* res, size_t n, io_engine& ioEngine) 72 | { 73 | assert(0 != n); 74 | for (size_t i = 0; i < n; i++) 75 | { 76 | res[i] = boost_strand::create(ioEngine); 77 | } 78 | } 79 | 80 | void boost_strand::create_multi(std::vector& res, size_t n, io_engine& ioEngine) 81 | { 82 | assert(0 != n); 83 | res.resize(n); 84 | for (size_t i = 0; i < n; i++) 85 | { 86 | res[i] = boost_strand::create(ioEngine); 87 | } 88 | } 89 | 90 | void boost_strand::create_multi(std::list& res, size_t n, io_engine& ioEngine) 91 | { 92 | assert(0 != n); 93 | res.clear(); 94 | for (size_t i = 0; i < n; i++) 95 | { 96 | res.push_front(boost_strand::create(ioEngine)); 97 | } 98 | } 99 | 100 | shared_strand boost_strand::clone() 101 | { 102 | assert(_ioEngine); 103 | return create(*_ioEngine); 104 | } 105 | 106 | bool boost_strand::in_this_ios() 107 | { 108 | assert(_ioEngine); 109 | return _ioEngine->runningInThisIos(); 110 | } 111 | 112 | bool boost_strand::sync_safe() 113 | { 114 | assert(_ioEngine); 115 | return 1 == _ioEngine->ioThreads(); 116 | } 117 | 118 | bool boost_strand::running_in_this_thread() 119 | { 120 | assert(_strand); 121 | return _strand->running_in_this_thread(); 122 | } 123 | 124 | bool boost_strand::empty(bool checkTick) 125 | { 126 | assert(_strand); 127 | assert(running_in_this_thread()); 128 | #ifdef ENABLE_NEXT_TICK 129 | return _strand->empty() && (checkTick ? _frontTickQueue.empty() && _backTickQueue.empty() : true); 130 | #else 131 | return _strand->empty(); 132 | #endif 133 | } 134 | 135 | bool boost_strand::is_running() 136 | { 137 | assert(_strand); 138 | return _strand->running(); 139 | } 140 | 141 | bool boost_strand::safe_is_running() 142 | { 143 | assert(_strand); 144 | return _strand->safe_running(); 145 | } 146 | 147 | size_t boost_strand::io_threads() 148 | { 149 | assert(_ioEngine); 150 | return _ioEngine->ioThreads(); 151 | } 152 | 153 | bool boost_strand::only_self() 154 | { 155 | assert(_strand); 156 | return _strand->only_self(); 157 | } 158 | 159 | io_engine& boost_strand::get_io_engine() 160 | { 161 | assert(_ioEngine); 162 | return *_ioEngine; 163 | } 164 | 165 | boost::asio::io_service& boost_strand::get_io_service() 166 | { 167 | assert(_ioEngine); 168 | return *_ioEngine; 169 | } 170 | 171 | ActorTimer_* boost_strand::actor_timer() 172 | { 173 | return _actorTimer; 174 | } 175 | 176 | overlap_timer* boost_strand::over_timer() 177 | { 178 | return _overTimer; 179 | } 180 | 181 | std::shared_ptr boost_strand::make_timer() 182 | { 183 | std::shared_ptr res = std::make_shared(_actorTimer); 184 | res->_weakThis = res; 185 | return res; 186 | } 187 | 188 | #ifdef ENABLE_NEXT_TICK 189 | bool boost_strand::ready_empty() 190 | { 191 | assert(_strand); 192 | return _strand->ready_empty(); 193 | } 194 | 195 | bool boost_strand::waiting_empty() 196 | { 197 | assert(_strand); 198 | return _strand->waiting_empty(); 199 | } 200 | 201 | void boost_strand::push_next_tick(wrap_next_tick_face* handler) 202 | { 203 | _backTickQueue.push_back(handler); 204 | } 205 | 206 | void boost_strand::run_tick_front() 207 | { 208 | if (_thisRoundCount) 209 | { 210 | return; 211 | } 212 | while (!_frontTickQueue.empty()) 213 | { 214 | wrap_next_tick_face* const tick = static_cast(_frontTickQueue.pop_front()); 215 | const size_t spaceSize = tick->invoke(); 216 | switch (MEM_ALIGN(spaceSize, NEXT_TICK_SPACE_SIZE) / NEXT_TICK_SPACE_SIZE) 217 | { 218 | case 1: _nextTickAlloc[0]->deallocate(tick); break; 219 | case 2: _nextTickAlloc[1]->deallocate(tick); break; 220 | case 3: case 4: _nextTickAlloc[2]->deallocate(tick); break; 221 | default: _reuMemAlloc->deallocate(tick); break; 222 | } 223 | } 224 | } 225 | 226 | void boost_strand::run_tick_back() 227 | { 228 | _thisRoundCount++; 229 | if (!ready_empty()) 230 | { 231 | return; 232 | } 233 | size_t tickCount = _thisRoundCount; 234 | _thisRoundCount = 0; 235 | while (!_backTickQueue.empty() && tickCount--) 236 | { 237 | wrap_next_tick_face* const tick = static_cast(_backTickQueue.pop_front()); 238 | const size_t spaceSize = tick->invoke(); 239 | switch (MEM_ALIGN(spaceSize, NEXT_TICK_SPACE_SIZE) / NEXT_TICK_SPACE_SIZE) 240 | { 241 | case 1: _nextTickAlloc[0]->deallocate(tick); break; 242 | case 2: _nextTickAlloc[1]->deallocate(tick); break; 243 | case 3: case 4: _nextTickAlloc[2]->deallocate(tick); break; 244 | default: _reuMemAlloc->deallocate(tick); break; 245 | } 246 | } 247 | if (!_backTickQueue.empty()) 248 | { 249 | _backTickQueue.swap(_frontTickQueue); 250 | if (waiting_empty()) 251 | { 252 | post(any_handler()); 253 | } 254 | } 255 | } 256 | 257 | void* boost_strand::alloc_space(size_t size) 258 | { 259 | switch (MEM_ALIGN(size, NEXT_TICK_SPACE_SIZE) / NEXT_TICK_SPACE_SIZE) 260 | { 261 | case 1: return !_nextTickAlloc[0]->overflow() ? _nextTickAlloc[0]->allocate() : NULL; 262 | case 2: return !_nextTickAlloc[1]->overflow() ? _nextTickAlloc[1]->allocate() : NULL; 263 | case 3: case 4: return !_nextTickAlloc[2]->overflow() ? _nextTickAlloc[2]->allocate() : NULL; 264 | } 265 | return NULL; 266 | } 267 | 268 | #endif //ENABLE_NEXT_TICK -------------------------------------------------------------------------------- /MyActor/actor/shared_strand.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/shared_strand.h -------------------------------------------------------------------------------- /MyActor/actor/stack_object.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/stack_object.h -------------------------------------------------------------------------------- /MyActor/actor/strand_ex.cpp: -------------------------------------------------------------------------------- 1 | #include "strand_ex.h" 2 | #include "io_engine.h" 3 | 4 | namespace boost 5 | { 6 | namespace asio 7 | { 8 | namespace detail 9 | { 10 | struct get_impl_ready_empty_strand_ex 11 | { 12 | bool _empty; 13 | }; 14 | 15 | struct get_impl_waiting_empty_strand_ex 16 | { 17 | bool _empty; 18 | }; 19 | 20 | struct get_impl_running_strand_ex 21 | { 22 | bool _running; 23 | }; 24 | 25 | struct get_impl_safe_running_strand_ex 26 | { 27 | bool _running; 28 | }; 29 | 30 | template <> 31 | void boost::asio::detail::strand_service::dispatch(boost::asio::detail::strand_service::implementation_type& impl, get_impl_ready_empty_strand_ex& fh) 32 | { 33 | fh._empty = impl->ready_queue_.empty(); 34 | } 35 | 36 | template <> 37 | void boost::asio::detail::strand_service::dispatch(boost::asio::detail::strand_service::implementation_type& impl, get_impl_waiting_empty_strand_ex& fh) 38 | { 39 | fh._empty = impl->waiting_queue_.empty(); 40 | } 41 | 42 | template <> 43 | void boost::asio::detail::strand_service::dispatch(boost::asio::detail::strand_service::implementation_type& impl, get_impl_running_strand_ex& fh) 44 | { 45 | fh._running = impl->locked_; 46 | } 47 | 48 | template <> 49 | void boost::asio::detail::strand_service::dispatch(boost::asio::detail::strand_service::implementation_type& impl, get_impl_safe_running_strand_ex& fh) 50 | { 51 | impl->mutex_.lock(); 52 | fh._running = impl->locked_; 53 | impl->mutex_.unlock(); 54 | } 55 | } 56 | } 57 | } 58 | ////////////////////////////////////////////////////////////////////////// 59 | 60 | StrandEx_::StrandEx_(io_engine& ios) 61 | : _service(boost::asio::use_service(ios)), 62 | _impl(new boost::asio::detail::strand_service::strand_impl()) {} 63 | 64 | StrandEx_::~StrandEx_() 65 | { 66 | delete _impl; 67 | } 68 | 69 | bool StrandEx_::running_in_this_thread() const 70 | { 71 | return boost::asio::detail::call_stack::contains(_impl) != 0; 72 | } 73 | 74 | bool StrandEx_::empty() const 75 | { 76 | return ready_empty() && waiting_empty(); 77 | } 78 | 79 | bool StrandEx_::ready_empty() const 80 | { 81 | boost::asio::detail::get_impl_ready_empty_strand_ex t; 82 | _service.dispatch((boost::asio::detail::strand_service::implementation_type&)_impl, t); 83 | return t._empty; 84 | } 85 | 86 | bool StrandEx_::waiting_empty() const 87 | { 88 | boost::asio::detail::get_impl_waiting_empty_strand_ex t; 89 | _service.dispatch((boost::asio::detail::strand_service::implementation_type&)_impl, t); 90 | return t._empty; 91 | } 92 | 93 | bool StrandEx_::running() const 94 | { 95 | assert(running_in_this_thread()); 96 | boost::asio::detail::get_impl_running_strand_ex t; 97 | _service.dispatch((boost::asio::detail::strand_service::implementation_type&)_impl, t); 98 | return t._running; 99 | } 100 | 101 | bool StrandEx_::safe_running() const 102 | { 103 | assert(!running_in_this_thread()); 104 | boost::asio::detail::get_impl_safe_running_strand_ex t; 105 | _service.dispatch((boost::asio::detail::strand_service::implementation_type&)_impl, t); 106 | return t._running; 107 | } 108 | 109 | bool StrandEx_::only_self() const 110 | { 111 | assert(running_in_this_thread()); 112 | #ifdef ASIO_CALL_STACK_DEPTH 113 | return 1 == boost::asio::detail::call_stack::stack_depth(); 114 | #else 115 | return true; 116 | #endif 117 | } -------------------------------------------------------------------------------- /MyActor/actor/strand_ex.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/strand_ex.h -------------------------------------------------------------------------------- /MyActor/actor/trace_stack.cpp: -------------------------------------------------------------------------------- 1 | #include "trace_stack.h" 2 | 3 | #if (defined ENABLE_DUMP_STACK || defined PRINT_ACTOR_STACK) 4 | #ifdef WIN32 5 | #include 6 | #include 7 | #include 8 | #ifdef _MSC_VER 9 | #pragma comment(lib, "Dbghelp.lib") 10 | #endif 11 | #elif __linux__ 12 | #include 13 | #if (__i386__ || __x86_64__) 14 | #include 15 | #endif 16 | #endif 17 | #endif 18 | 19 | #if (defined ENABLE_DUMP_STACK || defined PRINT_ACTOR_STACK) 20 | #ifdef WIN32 21 | bool sym_initialize() 22 | { 23 | DWORD symOpts = SymGetOptions(); 24 | symOpts |= SYMOPT_LOAD_LINES; 25 | symOpts |= SYMOPT_DEBUG; 26 | SymSetOptions(symOpts); 27 | return TRUE == SymInitialize(GetCurrentProcess(), NULL, TRUE); 28 | } 29 | 30 | size_t stack_walk(QWORD *pTrace, size_t maxDepth, CONTEXT *pContext) 31 | { 32 | STACKFRAME64 stackFrame64; 33 | HANDLE hProcess = GetCurrentProcess(); 34 | HANDLE hThread = GetCurrentThread(); 35 | size_t depth = 0; 36 | ZeroMemory(&stackFrame64, sizeof(stackFrame64)); 37 | #ifdef _MSC_VER 38 | __try 39 | #endif 40 | { 41 | #ifdef _WIN64 42 | stackFrame64.AddrPC.Offset = pContext->Rip; 43 | stackFrame64.AddrStack.Offset = pContext->Rsp; 44 | stackFrame64.AddrFrame.Offset = pContext->Rbp; 45 | #else 46 | stackFrame64.AddrPC.Offset = pContext->Eip; 47 | stackFrame64.AddrStack.Offset = pContext->Esp; 48 | stackFrame64.AddrFrame.Offset = pContext->Ebp; 49 | #endif 50 | stackFrame64.AddrPC.Mode = AddrModeFlat; 51 | stackFrame64.AddrStack.Mode = AddrModeFlat; 52 | stackFrame64.AddrFrame.Mode = AddrModeFlat; 53 | bool successed = true; 54 | while (successed && (depth < maxDepth)) 55 | { 56 | successed = TRUE == StackWalk64( 57 | #ifdef _WIN64 58 | IMAGE_FILE_MACHINE_AMD64, 59 | #else 60 | IMAGE_FILE_MACHINE_I386, 61 | #endif 62 | hProcess, 63 | hThread, 64 | &stackFrame64, 65 | pContext, 66 | NULL, 67 | SymFunctionTableAccess64, 68 | SymGetModuleBase64, 69 | NULL 70 | ); 71 | 72 | pTrace[depth] = stackFrame64.AddrPC.Offset; 73 | if (!successed || 0 == stackFrame64.AddrFrame.Offset) 74 | { 75 | break; 76 | } 77 | ++depth; 78 | } 79 | } 80 | #ifdef _MSC_VER 81 | __except (EXCEPTION_EXECUTE_HANDLER) {} 82 | #endif 83 | return depth; 84 | } 85 | 86 | size_t check_file_name(char* name) 87 | { 88 | size_t length = strlen(name); 89 | if (length) 90 | { 91 | name[length++] = '.'; 92 | size_t l = strlen(name + length); 93 | length += l ? l : -1; 94 | } 95 | return length; 96 | } 97 | 98 | extern "C" void __fastcall get_bp_sp_ip(void** pbp, void** psp, void** pip); 99 | 100 | std::list get_stack_list(size_t maxDepth, size_t offset, bool module, bool symbolName) 101 | { 102 | void* bp = NULL; 103 | void* sp = NULL; 104 | void* ip = NULL; 105 | get_bp_sp_ip((void**)&bp, (void**)&sp, (void**)&ip); 106 | return get_stack_list(bp, sp, ip, 2 + maxDepth, 2 + offset, module, symbolName); 107 | } 108 | 109 | std::list get_stack_list(void* bp, void* sp, void* ip, size_t maxDepth, size_t offset, bool module, bool symbolName) 110 | { 111 | assert(maxDepth <= 32); 112 | 113 | QWORD trace[33]; 114 | CONTEXT context; 115 | 116 | ZeroMemory(&context, sizeof(context)); 117 | context.ContextFlags = CONTEXT_FULL; 118 | #ifdef _WIN64 119 | context.Rbp = (DWORD64)bp; 120 | context.Rsp = (DWORD64)sp; 121 | context.Rip = (DWORD64)ip; 122 | #else 123 | context.Ebp = (DWORD)bp; 124 | context.Esp = (DWORD)sp; 125 | context.Eip = (DWORD)ip; 126 | #endif 127 | size_t depths = stack_walk(trace, maxDepth + 1, &context); 128 | std::list imageList; 129 | HANDLE hProcess = GetCurrentProcess(); 130 | for (size_t i = offset; i < depths; i++) 131 | { 132 | stack_line_info stackResult; 133 | { 134 | DWORD symbolDisplacement = 0; 135 | IMAGEHLP_LINE64 imageHelpLine; 136 | imageHelpLine.SizeOfStruct = sizeof(imageHelpLine); 137 | if (SymGetLineFromAddr64(hProcess, trace[i], &symbolDisplacement, &imageHelpLine)) 138 | { 139 | stackResult.file = std::string(imageHelpLine.FileName, check_file_name(imageHelpLine.FileName)); 140 | memset(imageHelpLine.FileName, 0, stackResult.file.size() + 1); 141 | stackResult.line = (int)imageHelpLine.LineNumber; 142 | } 143 | else 144 | { 145 | stackResult.line = -1; 146 | } 147 | } 148 | if (symbolName) 149 | { 150 | const int maxNameLength = 1024; 151 | char symbolBf[sizeof(IMAGEHLP_SYMBOL64)+maxNameLength] = { 0 }; 152 | PIMAGEHLP_SYMBOL64 symbol; 153 | DWORD64 symbolDisplacement64 = 0; 154 | symbol = (PIMAGEHLP_SYMBOL64)symbolBf; 155 | symbol->SizeOfStruct = sizeof(symbolBf); 156 | symbol->MaxNameLength = maxNameLength; 157 | stackResult.symbolName = SymGetSymFromAddr64(hProcess, trace[i], &symbolDisplacement64, symbol) ? symbol->Name : "unknow..."; 158 | } 159 | if (module) 160 | { 161 | IMAGEHLP_MODULE64 imageHelpModule; 162 | imageHelpModule.SizeOfStruct = sizeof(imageHelpModule); 163 | if (SymGetModuleInfo64(hProcess, trace[i], &imageHelpModule)) 164 | { 165 | stackResult.module = std::string(imageHelpModule.ImageName, check_file_name(imageHelpModule.ImageName)); 166 | memset(imageHelpModule.ImageName, 0, stackResult.module.size() + 1); 167 | } 168 | } 169 | imageList.push_back(std::move(stackResult)); 170 | } 171 | return imageList; 172 | } 173 | 174 | #ifdef PRINT_ACTOR_STACK 175 | run_thread* _thread = NULL; 176 | boost::asio::io_service* _stackLogIos = NULL; 177 | boost::asio::io_service::work* _stackLogWork = NULL; 178 | std::ofstream _stackLogFile; 179 | 180 | void stack_overflow_format(int size, const std::list& createStack) 181 | { 182 | stack_overflow_format(size, std::list(createStack)); 183 | } 184 | 185 | void stack_overflow_format(int size, std::list&& createStack) 186 | { 187 | if (_stackLogIos) 188 | { 189 | _stackLogIos->post(std::bind([size](std::list& createStack) 190 | { 191 | _stackLogFile << "---------------------------"; 192 | _stackLogFile << get_time_string_ms() << "---------------------------\r\n\r\n"; 193 | _stackLogFile << "overflow size: " << size << "\r\n\r\n"; 194 | for (stack_line_info& ele : createStack) 195 | { 196 | _stackLogFile << "file: " << ele.file << "\r\n"; 197 | _stackLogFile << "line: " << ele.line << "\r\n"; 198 | _stackLogFile << "module: " << ele.module << "\r\n"; 199 | _stackLogFile << "symbolName: " << ele.symbolName << "\r\n\r\n"; 200 | } 201 | }, std::move(createStack))); 202 | } 203 | } 204 | 205 | #endif 206 | 207 | void install_check_stack() 208 | { 209 | bool ok = sym_initialize(); 210 | assert(ok); 211 | #ifdef PRINT_ACTOR_STACK 212 | std::list stk = get_stack_list(1, 0, true, true); 213 | std::string moduleName; 214 | if (!stk.empty()) 215 | { 216 | moduleName = &stk.front().module[stk.front().module.find_last_of('\\') + 1]; 217 | } 218 | CreateDirectoryA((moduleName + " stack_log\\").c_str(), NULL); 219 | _stackLogFile.open(moduleName + " stack_log\\" + get_time_string_file_s() + ".log"); 220 | if (_stackLogFile.good()) 221 | { 222 | _stackLogIos = new boost::asio::io_service; 223 | _stackLogWork = new boost::asio::io_service::work(*_stackLogIos); 224 | _thread = new run_thread([&] 225 | { 226 | boost::system::error_code ec; 227 | _stackLogIos->run(ec); 228 | }); 229 | } 230 | else 231 | { 232 | _stackLogIos = NULL; 233 | _stackLogWork = NULL; 234 | _thread = NULL; 235 | } 236 | #endif 237 | } 238 | 239 | void uninstall_check_stack() 240 | { 241 | #ifdef PRINT_ACTOR_STACK 242 | if (_stackLogIos) 243 | { 244 | delete _stackLogWork; 245 | _thread->join(); 246 | delete _thread; 247 | delete _stackLogIos; 248 | _stackLogFile.close(); 249 | } 250 | #endif 251 | } 252 | 253 | #elif __linux__ 254 | ////////////////////////////////////////////////////////////////////////// 255 | 256 | void cut_file_line(const char* buff, int& length, int& line) 257 | { 258 | length = 0; 259 | line = -1; 260 | int i = 0; 261 | int lastColon = -1; 262 | while (buff[i]) 263 | { 264 | if (':' == buff[i]) 265 | { 266 | length = i; 267 | lastColon = i; 268 | } 269 | i++; 270 | } 271 | if (-1 != lastColon) 272 | { 273 | line = atoi(buff + lastColon + 1); 274 | } 275 | } 276 | 277 | #define ADDR2LINE "addr2line -f -e " 278 | 279 | std::list get_stack_list(void** traceback, size_t size, bool module, bool symbolName) 280 | { 281 | std::list imageList; 282 | char cmdHead[256] = ADDR2LINE; 283 | char *prog = cmdHead + (sizeof(ADDR2LINE)-1); 284 | const int moduleSize = readlink("/proc/self/exe", prog, sizeof(cmdHead)-(prog - cmdHead) - 1); 285 | if (moduleSize > 0) 286 | { 287 | const int prefixSize = (sizeof(ADDR2LINE)-1) + moduleSize; 288 | std::string cmd = cmdHead; 289 | for (size_t i = 0; i < size; i++) 290 | { 291 | char tmp[24]; 292 | snprintf(tmp, sizeof(tmp), " %p", traceback[i]); 293 | cmd.append(tmp); 294 | } 295 | FILE *fp = popen(cmd.c_str(), "r"); 296 | if (fp) 297 | { 298 | char buff[1024]; 299 | while (true) 300 | { 301 | stack_line_info stackResult; 302 | if (fgets(buff, sizeof(buff), fp)) 303 | { 304 | if (symbolName) 305 | { 306 | stackResult.symbolName = buff; 307 | if (!stackResult.symbolName.empty()) 308 | { 309 | stackResult.symbolName.resize(stackResult.symbolName.size()-1); 310 | } 311 | } 312 | if (module) 313 | { 314 | stackResult.module = std::string(cmdHead + (sizeof(ADDR2LINE)-1), moduleSize); 315 | } 316 | if (fgets(buff, sizeof(buff), fp)) 317 | { 318 | int length, line; 319 | cut_file_line(buff, length, line); 320 | stackResult.line = line; 321 | stackResult.file = std::string(buff, length); 322 | imageList.push_back(std::move(stackResult)); 323 | } 324 | else 325 | { 326 | break; 327 | } 328 | } 329 | else 330 | { 331 | break; 332 | } 333 | } 334 | pclose(fp); 335 | } 336 | } 337 | return imageList; 338 | } 339 | 340 | std::list get_stack_list(size_t maxDepth, size_t offset, bool module, bool symbolName) 341 | { 342 | assert(maxDepth && maxDepth <= 32); 343 | void* traceback[32]; 344 | int depth = backtrace(traceback, maxDepth); 345 | if (depth > (int)offset) 346 | { 347 | return get_stack_list(&traceback[offset], depth - offset, module, symbolName); 348 | } 349 | return std::list(); 350 | } 351 | 352 | std::list get_stack_list(void* reg_bp, void* reg_sp, void* reg_ip, size_t maxDepth, size_t offset, bool module, bool symbolName) 353 | { 354 | assert(maxDepth && maxDepth <= 32); 355 | std::vector traceback; 356 | #if (__i386__ || __x86_64__) 357 | void* ip = reg_ip; 358 | void** bp = (void**)reg_bp; 359 | while (bp && ip && traceback.size() < 32) 360 | { 361 | Dl_info dlinfo; 362 | if (!dladdr(ip, &dlinfo)) 363 | { 364 | break; 365 | } 366 | traceback.push_back(ip); 367 | ip = bp[1]; 368 | bp = (void**)bp[0]; 369 | } 370 | #elif (_ARM32 || _ARM64) 371 | //FIXME 372 | traceback.push_back(reg_ip); 373 | #endif 374 | if (traceback.size() > offset) 375 | { 376 | return get_stack_list(&traceback[offset], traceback.size() - offset, module, symbolName); 377 | } 378 | return std::list(); 379 | } 380 | 381 | void install_check_stack() 382 | { 383 | } 384 | 385 | void uninstall_check_stack() 386 | { 387 | } 388 | 389 | #endif 390 | #else 391 | void install_check_stack(){} 392 | void uninstall_check_stack(){} 393 | #endif -------------------------------------------------------------------------------- /MyActor/actor/trace_stack.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/trace_stack.h -------------------------------------------------------------------------------- /MyActor/actor/try_move.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/try_move.h -------------------------------------------------------------------------------- /MyActor/actor/tuple_option.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAM-2015/CPP-Actor-framework/a28188351e45f6720571a6083e7ad63e5c5bfad0/MyActor/actor/tuple_option.h -------------------------------------------------------------------------------- /MyActor/actor/uv_strand.cpp: -------------------------------------------------------------------------------- 1 | #include "uv_strand.h" 2 | 3 | #ifdef ENABLE_UV_ACTOR 4 | 5 | uv_strand::uv_tls::uv_tls() 6 | :_uvStack(64) 7 | { 8 | _count = 0; 9 | memset(_tlsBuff, 0, sizeof(_tlsBuff)); 10 | } 11 | 12 | uv_strand::uv_tls::~uv_tls() 13 | { 14 | assert(0 == _count); 15 | } 16 | 17 | void uv_strand::uv_tls::init() 18 | { 19 | void** const tlsBuff = io_engine::getTlsValueBuff(); 20 | if (tlsBuff) 21 | { 22 | uv_tls*& uvTls = (uv_tls*&)tlsBuff[UV_TLS_INDEX]; 23 | assert(uvTls); 24 | uvTls->_count++; 25 | } 26 | else 27 | { 28 | uv_tls* uvTls = new uv_tls(); 29 | uvTls->_count++; 30 | uvTls->_tlsBuff[UV_TLS_INDEX] = uvTls; 31 | io_engine::setTlsBuff(uvTls->_tlsBuff); 32 | } 33 | } 34 | 35 | void uv_strand::uv_tls::reset() 36 | { 37 | void** const tlsBuff = io_engine::getTlsValueBuff(); 38 | assert(tlsBuff); 39 | uv_tls* uvTls = (uv_tls*)tlsBuff[UV_TLS_INDEX]; 40 | if (0 == --uvTls->_count) 41 | { 42 | assert(tlsBuff == uvTls->_tlsBuff); 43 | io_engine::setTlsBuff(NULL); 44 | delete uvTls; 45 | } 46 | } 47 | 48 | uv_strand::uv_tls* uv_strand::uv_tls::push_stack(uv_strand* s) 49 | { 50 | assert(s); 51 | uv_tls* uvTls = (uv_tls*)io_engine::getTlsValue(UV_TLS_INDEX); 52 | assert(uvTls); 53 | uvTls->_uvStack.push_front(s); 54 | return uvTls; 55 | } 56 | 57 | uv_strand* uv_strand::uv_tls::pop_stack() 58 | { 59 | return pop_stack((uv_tls*)io_engine::getTlsValue(UV_TLS_INDEX)); 60 | } 61 | 62 | uv_strand* uv_strand::uv_tls::pop_stack(uv_tls* uvTls) 63 | { 64 | assert(uvTls && uvTls == (uv_tls*)io_engine::getTlsValue(UV_TLS_INDEX)); 65 | assert(!uvTls->_uvStack.empty()); 66 | uv_strand* r = uvTls->_uvStack.front(); 67 | uvTls->_uvStack.pop_front(); 68 | return r; 69 | } 70 | 71 | bool uv_strand::uv_tls::running_in_this_thread(uv_strand* s) 72 | { 73 | void** const tlsBuff = io_engine::getTlsValueBuff(); 74 | if (tlsBuff && tlsBuff[UV_TLS_INDEX]) 75 | { 76 | uv_tls* uvTls = (uv_tls*)tlsBuff[UV_TLS_INDEX]; 77 | for (uv_strand* const ele : uvTls->_uvStack) 78 | { 79 | if (ele == s) 80 | { 81 | return true; 82 | } 83 | } 84 | } 85 | return false; 86 | } 87 | 88 | size_t uv_strand::uv_tls::running_depth() 89 | { 90 | size_t dp = 0; 91 | void** const tlsBuff = io_engine::getTlsValueBuff(); 92 | if (tlsBuff && tlsBuff[UV_TLS_INDEX]) 93 | { 94 | uv_tls* uvTls = (uv_tls*)tlsBuff[UV_TLS_INDEX]; 95 | dp = uvTls->_uvStack.size(); 96 | } 97 | return dp; 98 | } 99 | ////////////////////////////////////////////////////////////////////////// 100 | 101 | uv_strand::hold_stack::hold_stack(uv_strand* strand) 102 | { 103 | assert(strand->in_this_ios()); 104 | _uvTls = uv_tls::push_stack(strand); 105 | } 106 | 107 | uv_strand::hold_stack::~hold_stack() 108 | { 109 | uv_tls::pop_stack(_uvTls); 110 | } 111 | ////////////////////////////////////////////////////////////////////////// 112 | 113 | uv_strand::uv_strand() 114 | { 115 | _uvLoop = NULL; 116 | _waitCount = 0; 117 | _locked = false; 118 | _doRunWait = false; 119 | _doRunSign = false; 120 | _waitClose = false; 121 | _uvReq = new uv_work_t; 122 | _uvReq->data = NULL; 123 | #if (ENABLE_QT_ACTOR && ENABLE_UV_ACTOR) 124 | _strandChoose = boost_strand::strand_uv; 125 | #endif 126 | uv_tls::init(); 127 | } 128 | 129 | uv_strand::~uv_strand() 130 | { 131 | assert(!_uvLoop && !_uvReq); 132 | } 133 | 134 | shared_uv_strand uv_strand::create(io_engine& ioEngine, uv_loop_t* uvLoop) 135 | { 136 | shared_uv_strand res = std::make_shared(); 137 | res->_ioEngine = &ioEngine; 138 | res->_uvLoop = uvLoop; 139 | res->_threadID = run_thread::this_thread_id(); 140 | res->_actorTimer = new ActorTimer_(res); 141 | res->_overTimer = new overlap_timer(res); 142 | res->_weakThis = res; 143 | return res; 144 | } 145 | 146 | void uv_strand::release() 147 | { 148 | assert(in_this_ios()); 149 | assert(!running_in_this_thread()); 150 | assert(!_locked); 151 | assert(!_doRunWait); 152 | assert(!_doRunSign); 153 | assert(!_waitClose); 154 | assert(!_waitCount); 155 | assert(_readyQueue.empty()); 156 | assert(_waitQueue.empty()); 157 | if (_uvReq->data) 158 | { 159 | _uvReq->data = NULL; 160 | } 161 | else 162 | { 163 | delete _uvReq; 164 | } 165 | _uvReq = NULL; 166 | _uvLoop = NULL; 167 | uv_tls::reset(); 168 | } 169 | 170 | bool uv_strand::released() 171 | { 172 | assert(in_this_ios()); 173 | return !_uvLoop; 174 | } 175 | 176 | shared_strand uv_strand::clone() 177 | { 178 | assert(_uvLoop); 179 | return create(*_ioEngine, _uvLoop); 180 | } 181 | 182 | bool uv_strand::in_this_ios() 183 | { 184 | return run_thread::this_thread_id() == _threadID; 185 | } 186 | 187 | bool uv_strand::running_in_this_thread() 188 | { 189 | assert(_uvLoop); 190 | return uv_tls::running_in_this_thread(this); 191 | } 192 | 193 | bool uv_strand::only_self() 194 | { 195 | assert(running_in_this_thread()); 196 | return 1 == uv_tls::running_depth(); 197 | } 198 | 199 | bool uv_strand::sync_safe() 200 | { 201 | return true; 202 | } 203 | 204 | bool uv_strand::is_running() 205 | { 206 | return true; 207 | } 208 | 209 | void uv_strand::post_task_event() 210 | { 211 | assert(!_uvReq->data); 212 | _uvReq->data = this; 213 | uv_queue_work(_uvLoop, _uvReq, [](uv_work_t*){}, [](uv_work_t* uv_op, int status) 214 | { 215 | if (uv_op->data) 216 | { 217 | uv_strand* this_ = (uv_strand*)uv_op->data; 218 | assert(this_->in_this_ios()); 219 | uv_op->data = NULL; 220 | this_->run_one_task(); 221 | } 222 | else 223 | { 224 | delete uv_op; 225 | } 226 | }); 227 | } 228 | 229 | void uv_strand::append_task(wrap_handler_face* h) 230 | { 231 | assert(_uvLoop); 232 | _queueMutex.lock(); 233 | if (_locked) 234 | { 235 | _waitQueue.push_back(h); 236 | _queueMutex.unlock(); 237 | } 238 | else 239 | { 240 | bool doNtf = _doRunWait; 241 | _doRunWait = false; 242 | _locked = true; 243 | _queueMutex.unlock(); 244 | _readyQueue.push_back(h); 245 | if (doNtf) 246 | { 247 | _doRunConVar.notify_one(); 248 | } 249 | else 250 | { 251 | post_task_event(); 252 | } 253 | } 254 | } 255 | 256 | void uv_strand::run_one_task() 257 | { 258 | uv_tls* uvTls = uv_tls::push_stack(this); 259 | while (!_readyQueue.empty()) 260 | { 261 | wrap_handler_face* h = static_cast(_readyQueue.pop_front()); 262 | h->invoke(); 263 | _reuMem.deallocate(h); 264 | } 265 | _queueMutex.lock(); 266 | if (!_waitQueue.empty()) 267 | { 268 | _waitQueue.swap(_readyQueue); 269 | _queueMutex.unlock(); 270 | post_task_event(); 271 | } 272 | else 273 | { 274 | _locked = false; 275 | _queueMutex.unlock(); 276 | } 277 | uv_strand* r = uv_tls::pop_stack(uvTls); 278 | assert(this == r); 279 | } 280 | 281 | void uv_strand::enter_wait_close() 282 | { 283 | assert(in_this_ios()); 284 | if (!_waitCount) 285 | { 286 | _doRunSign = true; 287 | } 288 | uv_tls* uvTls = uv_tls::push_stack(this); 289 | _waitClose = true; 290 | do 291 | { 292 | while (!_readyQueue.empty()) 293 | { 294 | wrap_handler_face* h = static_cast(_readyQueue.pop_front()); 295 | h->invoke(); 296 | _reuMem.deallocate(h); 297 | } 298 | std::unique_lock ul(_queueMutex); 299 | if (!_waitQueue.empty()) 300 | { 301 | _waitQueue.swap(_readyQueue); 302 | } 303 | else if (!_doRunSign) 304 | { 305 | _locked = false; 306 | _doRunWait = true; 307 | _doRunConVar.wait(ul); 308 | } 309 | else 310 | { 311 | _doRunSign = false; 312 | _locked = false; 313 | break; 314 | } 315 | } while (true); 316 | _waitClose = false; 317 | uv_strand* r = uv_tls::pop_stack(uvTls); 318 | assert(this == r); 319 | } 320 | 321 | uv_loop_t* uv_strand::uv_loop() 322 | { 323 | return _uvLoop; 324 | } 325 | 326 | void uv_strand::check_close() 327 | { 328 | assert(in_this_ios()); 329 | assert(_waitCount > 0); 330 | if (0 == --_waitCount && _waitClose) 331 | { 332 | _doRunSign = true; 333 | } 334 | } 335 | 336 | std::function uv_strand::wrap_check_close() 337 | { 338 | assert(in_this_ios()); 339 | _waitCount++; 340 | return FUNCTION_ALLOCATOR(std::function, wrap_post_once([this] 341 | { 342 | check_close(); 343 | }), (reusable_alloc>(_reuMem))); 344 | } 345 | 346 | bool uv_strand::is_wait_close() 347 | { 348 | assert(in_this_ios()); 349 | return _waitClose; 350 | } 351 | 352 | #endif -------------------------------------------------------------------------------- /MyActor/actor/uv_strand.h: -------------------------------------------------------------------------------- 1 | #ifndef __UV_STRAND_H 2 | #define __UV_STRAND_H 3 | 4 | #include "shared_strand.h" 5 | 6 | #ifdef ENABLE_UV_ACTOR 7 | #include "uv.h" 8 | 9 | class bind_uv_run; 10 | class uv_strand; 11 | typedef std::shared_ptr shared_uv_strand; 12 | 13 | #define BEGIN_CLOSE_UV(__uv_strand__) \ 14 | if (__uv_strand__ && !(__uv_strand__)->released() && !(__uv_strand__)->is_wait_close()) { \ 15 | uv_strand* const ___uv_strand = (__uv_strand__).get(); { 16 | 17 | #define WAIT_CLOSE_UV };___uv_strand->async_check_close([&]{ 18 | 19 | #define END_CLOSE_UV });} 20 | 21 | class uv_strand : public boost_strand 22 | { 23 | friend boost_strand; 24 | FRIEND_SHARED_PTR(uv_strand); 25 | 26 | struct uv_tls 27 | { 28 | uv_tls(); 29 | ~uv_tls(); 30 | 31 | static uv_tls* push_stack(uv_strand*); 32 | static uv_strand* pop_stack(); 33 | static uv_strand* pop_stack(uv_tls*); 34 | static bool running_in_this_thread(uv_strand*); 35 | static size_t running_depth(); 36 | static void init(); 37 | static void reset(); 38 | 39 | msg_list > > _uvStack; 40 | void* _tlsBuff[64]; 41 | int _count; 42 | }; 43 | 44 | struct wrap_handler_face : public op_queue::face 45 | { 46 | virtual void invoke() = 0; 47 | }; 48 | 49 | template 50 | struct wrap_handler : public wrap_handler_face 51 | { 52 | typedef RM_CREF(Handler) handler_type; 53 | 54 | wrap_handler(Handler& handler) 55 | :_handler(std::forward(handler)) {} 56 | 57 | void invoke() 58 | { 59 | CHECK_EXCEPTION(_handler); 60 | this->~wrap_handler(); 61 | } 62 | 63 | handler_type _handler; 64 | }; 65 | 66 | template 67 | wrap_handler_face* make_wrap_handler(reusable_mem_mt<>& reuMem, Handler&& handler) 68 | { 69 | typedef wrap_handler handler_type; 70 | return new(reuMem.allocate(sizeof(handler_type)))handler_type(handler); 71 | } 72 | public: 73 | class hold_stack 74 | { 75 | public: 76 | hold_stack(uv_strand* strand); 77 | ~hold_stack(); 78 | private: 79 | uv_tls* _uvTls; 80 | private: 81 | void* operator new(size_t){ return NULL; }; 82 | void operator delete(void*){}; 83 | NONE_COPY(hold_stack); 84 | }; 85 | private: 86 | uv_strand(); 87 | ~uv_strand(); 88 | public: 89 | static shared_uv_strand create(io_engine& ioEngine, uv_loop_t* uvLoop = uv_default_loop()); 90 | void release(); 91 | bool released(); 92 | shared_strand clone(); 93 | bool in_this_ios(); 94 | bool running_in_this_thread(); 95 | bool only_self(); 96 | bool sync_safe(); 97 | bool is_running(); 98 | void enter_wait_close(); 99 | bool is_wait_close(); 100 | uv_loop_t* uv_loop(); 101 | private: 102 | template 103 | void _dispatch_uv(Handler&& handler) 104 | { 105 | _post_uv(std::forward(handler)); 106 | } 107 | 108 | template 109 | void _post_uv(Handler&& handler) 110 | { 111 | append_task(make_wrap_handler(_reuMem, std::forward(handler))); 112 | } 113 | 114 | void post_task_event(); 115 | void append_task(wrap_handler_face*); 116 | void run_one_task(); 117 | void check_close(); 118 | public: 119 | template 120 | std::function wrap_check_close(Handler&& handler) 121 | { 122 | assert(in_this_ios()); 123 | _waitCount++; 124 | return FUNCTION_ALLOCATOR(std::function, wrap_post_once(std::bind([this](Handler& handler) 125 | { 126 | CHECK_EXCEPTION(handler); 127 | check_close(); 128 | }, std::forward(handler))), (reusable_alloc>(_reuMem))); 129 | } 130 | 131 | std::function wrap_check_close(); 132 | 133 | template 134 | void async_check_close(Handler&& handler) 135 | { 136 | assert(in_this_ios()); 137 | if (_waitCount) 138 | { 139 | _waitClose = true; 140 | setImmediate(std::bind([this](Handler& handler) 141 | { 142 | async_check_close(std::forward(handler)); 143 | }, std::forward(handler))); 144 | } 145 | else 146 | { 147 | enter_wait_close(); 148 | CHECK_EXCEPTION(handler); 149 | } 150 | } 151 | public: 152 | template 153 | bool noTopCall(Handler&& handler) 154 | { 155 | assert(in_this_ios()); 156 | if (!released() && running_in_this_thread()) 157 | { 158 | uv_strand::setImmediate(std::forward(handler), _uvLoop); 159 | return false; 160 | } 161 | CHECK_EXCEPTION(handler); 162 | return true; 163 | } 164 | 165 | template 166 | static void setImmediate(Handler&& handler, uv_loop_t* uvLoop = uv_default_loop()) 167 | { 168 | typedef wrap_handler handler_type; 169 | uv_work_t* uvReq = new uv_work_t; 170 | uvReq->data = new(malloc(sizeof(handler_type)))handler_type(handler); 171 | uv_queue_work(uvLoop, uvReq, [](uv_work_t*){}, [](uv_work_t* uv_op, int status) 172 | { 173 | ((handler_type*)uv_op->data)->invoke(); 174 | free(uv_op->data); 175 | delete uv_op; 176 | }); 177 | } 178 | private: 179 | uv_loop_t* _uvLoop; 180 | uv_work_t* _uvReq; 181 | run_thread::thread_id _threadID; 182 | reusable_mem_mt<> _reuMem; 183 | std::mutex _queueMutex; 184 | std::condition_variable _doRunConVar; 185 | op_queue _waitQueue; 186 | op_queue _readyQueue; 187 | int _waitCount; 188 | bool _doRunSign; 189 | bool _waitClose; 190 | bool _doRunWait; 191 | bool _locked; 192 | }; 193 | 194 | #endif 195 | #endif -------------------------------------------------------------------------------- /MyActor/actor/waitable_timer.cpp: -------------------------------------------------------------------------------- 1 | #ifdef DISABLE_BOOST_TIMER 2 | #include "waitable_timer.h" 3 | #include "scattered.h" 4 | #ifdef WIN32 5 | #include 6 | 7 | WaitableTimer_::WaitableTimer_() 8 | :_eventsQueue(1024), _exited(false), _extMaxTick(0), _extFinishTime(-1), 9 | _timerHandle(CreateWaitableTimer(NULL, FALSE, NULL)) 10 | { 11 | run_thread th([this] { timerThread(); }); 12 | _timerThread.swap(th); 13 | } 14 | 15 | WaitableTimer_::~WaitableTimer_() 16 | { 17 | { 18 | std::lock_guard lg(_ctrlMutex); 19 | assert(_eventsQueue.empty()); 20 | _exited = true; 21 | LARGE_INTEGER sleepTime; 22 | sleepTime.QuadPart = 0; 23 | SetWaitableTimer(_timerHandle, &sleepTime, 0, NULL, NULL, FALSE); 24 | } 25 | _timerThread.join(); 26 | CloseHandle(_timerHandle); 27 | } 28 | 29 | void WaitableTimer_::appendEvent(long long abs, long long rel, WaitableTimerEvent_* h) 30 | { 31 | assert(h->_timerHandle._null); 32 | h->_timerHandle._null = false; 33 | std::lock_guard lg(_ctrlMutex); 34 | if (abs >= _extMaxTick) 35 | { 36 | _extMaxTick = abs; 37 | h->_timerHandle._queueNode = _eventsQueue.insert(_eventsQueue.end(), std::make_pair(abs, h)); 38 | } 39 | else 40 | { 41 | h->_timerHandle._queueNode = _eventsQueue.insert(std::make_pair(abs, h)); 42 | } 43 | if ((unsigned long long)abs < (unsigned long long)_extFinishTime) 44 | { 45 | _extFinishTime = abs; 46 | LARGE_INTEGER sleepTime; 47 | sleepTime.QuadPart = -(LONGLONG)(rel * 10); 48 | SetWaitableTimer(_timerHandle, &sleepTime, 0, NULL, NULL, FALSE); 49 | } 50 | } 51 | 52 | void WaitableTimer_::timerThread() 53 | { 54 | run_thread::set_current_thread_name("waitable timer thread"); 55 | SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); 56 | while (true) 57 | { 58 | if (WAIT_OBJECT_0 == WaitForSingleObject(_timerHandle, INFINITE) && !_exited) 59 | { 60 | long long ct = get_tick_us(); 61 | std::lock_guard lg(_ctrlMutex); 62 | _extFinishTime = -1; 63 | while (!_eventsQueue.empty()) 64 | { 65 | handler_queue::iterator iter = _eventsQueue.begin(); 66 | if (iter->first > ct) 67 | { 68 | _extFinishTime = iter->first; 69 | LARGE_INTEGER sleepTime; 70 | sleepTime.QuadPart = -(LONGLONG)((iter->first - ct) * 10); 71 | SetWaitableTimer(_timerHandle, &sleepTime, 0, NULL, NULL, FALSE); 72 | break; 73 | } 74 | else 75 | { 76 | iter->second->eventHandler(); 77 | _eventsQueue.erase(iter); 78 | } 79 | } 80 | } 81 | else 82 | { 83 | break; 84 | } 85 | } 86 | } 87 | #elif __linux__ 88 | #include 89 | #include 90 | 91 | WaitableTimer_::WaitableTimer_() 92 | :_eventsQueue(1024), _exited(false), _extMaxTick(0), _extFinishTime(-1), 93 | _timerFd(timerfd_create(CLOCK_MONOTONIC, 0)) 94 | { 95 | run_thread th([this] { timerThread(); }); 96 | _timerThread.swap(th); 97 | } 98 | 99 | WaitableTimer_::~WaitableTimer_() 100 | { 101 | { 102 | std::lock_guard lg(_ctrlMutex); 103 | assert(_eventsQueue.empty()); 104 | _exited = true; 105 | struct itimerspec newValue = { { 0, 0 }, { 0, 1 } }; 106 | timerfd_settime(_timerFd, TFD_TIMER_ABSTIME, &newValue, NULL); 107 | } 108 | _timerThread.join(); 109 | close(_timerFd); 110 | } 111 | 112 | void WaitableTimer_::appendEvent(long long abs, long long rel, WaitableTimerEvent_* h) 113 | { 114 | assert(h->_timerHandle._null); 115 | h->_timerHandle._null = false; 116 | std::lock_guard lg(_ctrlMutex); 117 | if (abs >= _extMaxTick) 118 | { 119 | _extMaxTick = abs; 120 | h->_timerHandle._queueNode = _eventsQueue.insert(_eventsQueue.end(), std::make_pair(abs, h)); 121 | } 122 | else 123 | { 124 | h->_timerHandle._queueNode = _eventsQueue.insert(std::make_pair(abs, h)); 125 | } 126 | if ((unsigned long long)abs < (unsigned long long)_extFinishTime) 127 | { 128 | _extFinishTime = abs; 129 | struct itimerspec newValue; 130 | newValue.it_interval = { 0, 0 }; 131 | newValue.it_value.tv_sec = (__time_t)(abs / 1000000); 132 | newValue.it_value.tv_nsec = (long)(abs % 1000000) * 1000; 133 | timerfd_settime(_timerFd, TFD_TIMER_ABSTIME, &newValue, NULL); 134 | } 135 | } 136 | 137 | void WaitableTimer_::timerThread() 138 | { 139 | run_thread::set_current_thread_name("waitable timer thread"); 140 | pthread_attr_t threadAttr; 141 | struct sched_param pm = { 83 }; 142 | pthread_attr_init(&threadAttr); 143 | pthread_attr_setschedpolicy(&threadAttr, SCHED_FIFO); 144 | pthread_attr_setschedparam(&threadAttr, &pm); 145 | long long exp = 0; 146 | while (true) 147 | { 148 | if (sizeof(exp) == read(_timerFd, &exp, sizeof(exp)) && !_exited) 149 | { 150 | long long ct = get_tick_us(); 151 | std::lock_guard lg(_ctrlMutex); 152 | _extFinishTime = -1; 153 | while (!_eventsQueue.empty()) 154 | { 155 | handler_queue::iterator iter = _eventsQueue.begin(); 156 | if (iter->first > ct) 157 | { 158 | _extFinishTime = iter->first; 159 | struct itimerspec newValue; 160 | newValue.it_interval = { 0, 0 }; 161 | newValue.it_value.tv_sec = (__time_t)(_extFinishTime / 1000000); 162 | newValue.it_value.tv_nsec = (long)(_extFinishTime % 1000000) * 1000; 163 | timerfd_settime(_timerFd, TFD_TIMER_ABSTIME, &newValue, NULL); 164 | break; 165 | } 166 | else 167 | { 168 | iter->second->eventHandler(); 169 | _eventsQueue.erase(iter); 170 | } 171 | } 172 | } 173 | else 174 | { 175 | break; 176 | } 177 | } 178 | pthread_attr_destroy(&threadAttr); 179 | } 180 | #endif 181 | 182 | void WaitableTimer_::removeEvent(timer_handle& th) 183 | { 184 | std::lock_guard lg(_ctrlMutex); 185 | if (!th._null) 186 | { 187 | th._null = true; 188 | auto itNode = th._queueNode; 189 | if (_eventsQueue.size() == 1) 190 | { 191 | _extMaxTick = 0; 192 | _extFinishTime = -1; 193 | _eventsQueue.erase(itNode); 194 | } 195 | else if (itNode->first == _extMaxTick) 196 | { 197 | _eventsQueue.erase(itNode++); 198 | if (_eventsQueue.end() == itNode) 199 | { 200 | itNode--; 201 | } 202 | _extMaxTick = itNode->first; 203 | } 204 | else 205 | { 206 | _eventsQueue.erase(itNode); 207 | } 208 | } 209 | } 210 | ////////////////////////////////////////////////////////////////////////// 211 | 212 | WaitableTimerEvent_::WaitableTimerEvent_(io_engine& ios, TimerBoostCompletedEventFace_* timerBoost) 213 | :_ios(ios), _timerBoost(timerBoost), _tcId(-1), _triged(true) {} 214 | 215 | WaitableTimerEvent_::~WaitableTimerEvent_() 216 | { 217 | assert(_triged); 218 | } 219 | 220 | void WaitableTimerEvent_::eventHandler() 221 | { 222 | _timerHandle.reset(); 223 | _triged = true; 224 | _timerBoost->post_event(_tcId); 225 | } 226 | 227 | void WaitableTimerEvent_::cancel(boost::system::error_code& ec) 228 | { 229 | ec.clear(); 230 | _ios._waitableTimer->removeEvent(_timerHandle); 231 | if (!_triged) 232 | { 233 | _triged = true; 234 | _timerBoost->cancel_event(); 235 | } 236 | } 237 | 238 | void WaitableTimerEvent_::async_wait(long long abs, long long rel, int tc) 239 | { 240 | assert(_triged); 241 | _triged = false; 242 | _tcId = tc; 243 | _ios._waitableTimer->appendEvent(abs, rel, this); 244 | } 245 | 246 | #endif -------------------------------------------------------------------------------- /MyActor/actor/waitable_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __WAITABLE_TIMER_H 2 | #define __WAITABLE_TIMER_H 3 | 4 | #ifdef DISABLE_BOOST_TIMER 5 | #include "msg_queue.h" 6 | #include "mem_pool.h" 7 | #include "run_strand.h" 8 | #include "run_thread.h" 9 | 10 | class ActorTimer_; 11 | class WaitableTimerEvent_; 12 | class overlap_timer; 13 | 14 | class WaitableTimer_ 15 | { 16 | typedef msg_multimap handler_queue; 17 | 18 | struct timer_handle 19 | { 20 | void reset() 21 | { 22 | _null = true; 23 | } 24 | 25 | bool _null = true; 26 | handler_queue::iterator _queueNode; 27 | }; 28 | 29 | friend io_engine; 30 | friend WaitableTimerEvent_; 31 | private: 32 | WaitableTimer_(); 33 | ~WaitableTimer_(); 34 | private: 35 | void appendEvent(long long abs, long long rel, WaitableTimerEvent_* h); 36 | void removeEvent(timer_handle& th); 37 | void timerThread(); 38 | private: 39 | long long _extMaxTick; 40 | long long _extFinishTime; 41 | handler_queue _eventsQueue; 42 | std::mutex _ctrlMutex; 43 | run_thread _timerThread; 44 | #ifdef WIN32 45 | void* _timerHandle; 46 | #elif __linux__ 47 | int _timerFd; 48 | #endif 49 | volatile bool _exited; 50 | NONE_COPY(WaitableTimer_); 51 | }; 52 | 53 | class WaitableTimerEvent_ 54 | { 55 | friend ActorTimer_; 56 | friend WaitableTimer_; 57 | friend overlap_timer; 58 | private: 59 | WaitableTimerEvent_(io_engine& ios, TimerBoostCompletedEventFace_* timerBoost); 60 | ~WaitableTimerEvent_(); 61 | private: 62 | void eventHandler(); 63 | void cancel(boost::system::error_code& ec); 64 | void async_wait(long long abs, long long rel, int tc); 65 | private: 66 | io_engine& _ios; 67 | WaitableTimer_::timer_handle _timerHandle; 68 | TimerBoostCompletedEventFace_* _timerBoost; 69 | int _tcId; 70 | bool _triged; 71 | NONE_COPY(WaitableTimerEvent_); 72 | }; 73 | #endif 74 | 75 | #endif -------------------------------------------------------------------------------- /MyActor/actor/wrapped_capture.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAPPED_CAPTURE_H 2 | #define __WRAPPED_CAPTURE_H 3 | 4 | #include "tuple_option.h" 5 | #include 6 | #include 7 | 8 | template 9 | struct wrapped_capture 10 | { 11 | typedef RM_CREF(Handler) handler_type; 12 | 13 | wrapped_capture(bool pl, Handler& handler, Args&... args) 14 | :_handler(std::forward(handler)), _args(std::forward(args)...) {} 15 | 16 | wrapped_capture(const wrapped_capture& s) 17 | :_handler(s._handler), _args(s._args) {} 18 | 19 | wrapped_capture(wrapped_capture&& s) 20 | :_handler(std::move(s._handler)), _args(std::move(s._args)) {} 21 | 22 | void operator =(const wrapped_capture& s) 23 | { 24 | _handler = s._handler; 25 | _args = s._args; 26 | } 27 | 28 | void operator =(wrapped_capture&& s) 29 | { 30 | _handler = std::move(s._handler); 31 | _args = std::move(s._args); 32 | } 33 | 34 | void operator ()() 35 | { 36 | tuple_invoke(_handler, _args); 37 | } 38 | 39 | handler_type _handler; 40 | std::tuple _args; 41 | }; 42 | 43 | template 44 | wrapped_capture wrap_capture(Handler&& handler, Args&&... args) 45 | { 46 | return wrapped_capture(bool(), handler, args...); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /MyActor/actor/wrapped_dispatch_handler.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAPPED_DISPATCH_HANDLER_H 2 | #define __WRAPPED_DISPATCH_HANDLER_H 3 | 4 | #include "wrapped_capture.h" 5 | 6 | template 7 | class wrapped_dispatch_handler 8 | { 9 | typedef RM_CREF(Handler) handler_type; 10 | public: 11 | wrapped_dispatch_handler(Dispatcher* dispatcher, Handler& handler) 12 | : _dispatcher(dispatcher), 13 | _handler(std::forward(handler)) 14 | { 15 | } 16 | 17 | template 18 | wrapped_dispatch_handler(wrapped_dispatch_handler&& sd) 19 | :_dispatcher(sd._dispatcher), 20 | _handler(std::move(sd._handler)) 21 | { 22 | } 23 | 24 | template 25 | void operator=(wrapped_dispatch_handler&& sd) 26 | { 27 | _dispatcher = sd._dispatcher; 28 | _handler = std::move(sd._handler); 29 | } 30 | 31 | template 32 | void operator()(Args&&... args) 33 | { 34 | _dispatcher->dispatch(wrap_capture(_handler, std::forward(args)...)); 35 | } 36 | 37 | void operator()() 38 | { 39 | _dispatcher->dispatch(_handler); 40 | } 41 | 42 | Dispatcher* _dispatcher; 43 | handler_type _handler; 44 | }; 45 | ////////////////////////////////////////////////////////////////////////// 46 | 47 | template 48 | class wrapped_dispatch_handler 49 | { 50 | typedef RM_CREF(Handler) handler_type; 51 | public: 52 | wrapped_dispatch_handler(Dispatcher* dispatcher, Handler& handler) 53 | : _dispatcher(dispatcher), 54 | _handler(std::forward(handler)) 55 | #if (_DEBUG || DEBUG) 56 | , _checkOnce(std::make_shared>(false)) 57 | #endif 58 | { 59 | } 60 | 61 | template 62 | wrapped_dispatch_handler(wrapped_dispatch_handler&& sd) 63 | :_dispatcher(sd._dispatcher), 64 | _handler(std::move(sd._handler)) 65 | #if (_DEBUG || DEBUG) 66 | , _checkOnce(sd._checkOnce) 67 | #endif 68 | { 69 | } 70 | 71 | template 72 | void operator=(wrapped_dispatch_handler&& sd) 73 | { 74 | _dispatcher = sd._dispatcher; 75 | _handler = std::move(sd._handler); 76 | #if (_DEBUG || DEBUG) 77 | _checkOnce = sd._checkOnce; 78 | #endif 79 | } 80 | 81 | template 82 | void operator()(Args&&... args) 83 | { 84 | assert(!_checkOnce->exchange(true)); 85 | _dispatcher->dispatch(wrap_capture(std::move(_handler), std::forward(args)...)); 86 | } 87 | 88 | void operator()() 89 | { 90 | assert(!_checkOnce->exchange(true)); 91 | _dispatcher->dispatch(std::move(_handler)); 92 | } 93 | 94 | Dispatcher* _dispatcher; 95 | handler_type _handler; 96 | #if (_DEBUG || DEBUG) 97 | std::shared_ptr > _checkOnce; 98 | #endif 99 | }; 100 | #endif -------------------------------------------------------------------------------- /MyActor/actor/wrapped_distribute_handler.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAPPED_DISTRIBUTE_HANDLER_H 2 | #define __WRAPPED_DISTRIBUTE_HANDLER_H 3 | 4 | #include "wrapped_capture.h" 5 | 6 | template 7 | class wrapped_distribute_handler 8 | { 9 | typedef RM_CREF(Handler) handler_type; 10 | public: 11 | wrapped_distribute_handler(Distributier* distributier, Handler& handler) 12 | : _distributier(distributier), 13 | _handler(std::forward(handler)) 14 | { 15 | } 16 | 17 | template 18 | wrapped_distribute_handler(wrapped_distribute_handler&& sd) 19 | :_distributier(sd._distributier), 20 | _handler(std::move(sd._handler)) 21 | { 22 | } 23 | 24 | template 25 | void operator=(wrapped_distribute_handler&& sd) 26 | { 27 | _distributier = sd._distributier; 28 | _handler = std::move(sd._handler); 29 | } 30 | 31 | template 32 | void operator()(Args&&... args) 33 | { 34 | _distributier->distribute(wrap_capture(_handler, std::forward(args)...)); 35 | } 36 | 37 | void operator()() 38 | { 39 | _distributier->distribute(_handler); 40 | } 41 | 42 | Distributier* _distributier; 43 | handler_type _handler; 44 | }; 45 | ////////////////////////////////////////////////////////////////////////// 46 | 47 | template 48 | class wrapped_distribute_handler 49 | { 50 | typedef RM_CREF(Handler) handler_type; 51 | public: 52 | wrapped_distribute_handler(Distributier* distributier, Handler& handler) 53 | : _distributier(distributier), 54 | _handler(std::forward(handler)) 55 | #if (_DEBUG || DEBUG) 56 | , _checkOnce(std::make_shared>(false)) 57 | #endif 58 | { 59 | } 60 | 61 | template 62 | wrapped_distribute_handler(wrapped_distribute_handler&& sd) 63 | :_distributier(sd._distributier), 64 | _handler(std::move(sd._handler)) 65 | #if (_DEBUG || DEBUG) 66 | , _checkOnce(sd._checkOnce) 67 | #endif 68 | { 69 | } 70 | 71 | template 72 | void operator=(wrapped_distribute_handler&& sd) 73 | { 74 | _distributier = sd._distributier; 75 | _handler = std::move(sd._handler); 76 | #if (_DEBUG || DEBUG) 77 | _checkOnce = sd._checkOnce; 78 | #endif 79 | } 80 | 81 | template 82 | void operator()(Args&&... args) 83 | { 84 | assert(!_checkOnce->exchange(true)); 85 | _distributier->distribute(wrap_capture(std::move(_handler), std::forward(args)...)); 86 | } 87 | 88 | void operator()() 89 | { 90 | assert(!_checkOnce->exchange(true)); 91 | _distributier->distribute(std::move(_handler)); 92 | } 93 | 94 | Distributier* _distributier; 95 | handler_type _handler; 96 | #if (_DEBUG || DEBUG) 97 | std::shared_ptr > _checkOnce; 98 | #endif 99 | }; 100 | #endif -------------------------------------------------------------------------------- /MyActor/actor/wrapped_next_tick_handler.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAPPED_NEXT_TICK_HANDLER_H 2 | #define __WRAPPED_NEXT_TICK_HANDLER_H 3 | 4 | #include "wrapped_capture.h" 5 | 6 | template 7 | class wrapped_next_tick_handler 8 | { 9 | typedef RM_CREF(Handler) handler_type; 10 | public: 11 | wrapped_next_tick_handler(Poster* poster, Handler& handler) 12 | : _poster(poster), 13 | _handler(std::forward(handler)) 14 | { 15 | } 16 | 17 | template 18 | wrapped_next_tick_handler(wrapped_next_tick_handler&& sp) 19 | :_poster(sp._poster), 20 | _handler(std::move(sp._handler)) 21 | { 22 | } 23 | 24 | template 25 | void operator=(wrapped_next_tick_handler&& sp) 26 | { 27 | _poster = sp._poster; 28 | _handler = std::move(sp._handler); 29 | } 30 | 31 | template 32 | void operator()(Args&&... args) 33 | { 34 | _poster->next_tick(wrap_capture(_handler, std::forward(args)...)); 35 | } 36 | 37 | void operator()() 38 | { 39 | _poster->next_tick(_handler); 40 | } 41 | 42 | Poster* _poster; 43 | handler_type _handler; 44 | }; 45 | ////////////////////////////////////////////////////////////////////////// 46 | 47 | template 48 | class wrapped_next_tick_handler 49 | { 50 | typedef RM_CREF(Handler) handler_type; 51 | public: 52 | wrapped_next_tick_handler(Poster* poster, Handler& handler) 53 | : _poster(poster), 54 | _handler(std::forward(handler)) 55 | #if (_DEBUG || DEBUG) 56 | , _checkOnce(std::make_shared>(false)) 57 | #endif 58 | { 59 | } 60 | 61 | template 62 | wrapped_next_tick_handler(wrapped_next_tick_handler&& sd) 63 | :_poster(sd._poster), 64 | _handler(std::move(sd._handler)) 65 | #if (_DEBUG || DEBUG) 66 | , _checkOnce(sd._checkOnce) 67 | #endif 68 | { 69 | } 70 | 71 | template 72 | void operator=(wrapped_next_tick_handler&& sd) 73 | { 74 | _poster = sd._poster; 75 | _handler = std::move(sd._handler); 76 | #if (_DEBUG || DEBUG) 77 | _checkOnce = sd._checkOnce; 78 | #endif 79 | } 80 | 81 | template 82 | void operator()(Args&&... args) 83 | { 84 | assert(!_checkOnce->exchange(true)); 85 | _poster->next_tick(wrap_capture(std::move(_handler), std::forward(args)...)); 86 | } 87 | 88 | void operator()() 89 | { 90 | assert(!_checkOnce->exchange(true)); 91 | _poster->next_tick(std::move(_handler)); 92 | } 93 | 94 | Poster* _poster; 95 | handler_type _handler; 96 | #if (_DEBUG || DEBUG) 97 | std::shared_ptr > _checkOnce; 98 | #endif 99 | }; 100 | 101 | #endif -------------------------------------------------------------------------------- /MyActor/actor/wrapped_post_handler.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAPPED_POST_HANDLER_H 2 | #define __WRAPPED_POST_HANDLER_H 3 | 4 | #include "wrapped_capture.h" 5 | 6 | template 7 | class wrapped_post_handler 8 | { 9 | typedef RM_CREF(Handler) handler_type; 10 | public: 11 | wrapped_post_handler(Poster* poster, Handler& handler) 12 | : _poster(poster), 13 | _handler(std::forward(handler)) 14 | { 15 | } 16 | 17 | template 18 | wrapped_post_handler(wrapped_post_handler&& sp) 19 | :_poster(sp._poster), 20 | _handler(std::move(sp._handler)) 21 | { 22 | } 23 | 24 | template 25 | void operator=(wrapped_post_handler&& sp) 26 | { 27 | _poster = sp._poster; 28 | _handler = std::move(sp._handler); 29 | } 30 | 31 | template 32 | void operator()(Args&&... args) 33 | { 34 | _poster->post(wrap_capture(_handler, std::forward(args)...)); 35 | } 36 | 37 | void operator()() 38 | { 39 | _poster->post(_handler); 40 | } 41 | 42 | Poster* _poster; 43 | handler_type _handler; 44 | }; 45 | ////////////////////////////////////////////////////////////////////////// 46 | 47 | template 48 | class wrapped_post_handler 49 | { 50 | typedef RM_CREF(Handler) handler_type; 51 | public: 52 | wrapped_post_handler(Poster* poster, Handler& handler) 53 | : _poster(poster), 54 | _handler(std::forward(handler)) 55 | #if (_DEBUG || DEBUG) 56 | , _checkOnce(std::make_shared>(false)) 57 | #endif 58 | { 59 | } 60 | 61 | template 62 | wrapped_post_handler(wrapped_post_handler&& sd) 63 | :_poster(sd._poster), 64 | _handler(std::move(sd._handler)) 65 | #if (_DEBUG || DEBUG) 66 | , _checkOnce(sd._checkOnce) 67 | #endif 68 | { 69 | } 70 | 71 | template 72 | void operator=(wrapped_post_handler&& sd) 73 | { 74 | _poster = sd._poster; 75 | _handler = std::move(sd._handler); 76 | #if (_DEBUG || DEBUG) 77 | _checkOnce = sd._checkOnce; 78 | #endif 79 | } 80 | 81 | template 82 | void operator()(Args&&... args) 83 | { 84 | assert(!_checkOnce->exchange(true)); 85 | _poster->post(wrap_capture(std::move(_handler), std::forward(args)...)); 86 | } 87 | 88 | void operator()() 89 | { 90 | assert(!_checkOnce->exchange(true)); 91 | _poster->post(std::move(_handler)); 92 | } 93 | 94 | Poster* _poster; 95 | handler_type _handler; 96 | #if (_DEBUG || DEBUG) 97 | std::shared_ptr > _checkOnce; 98 | #endif 99 | }; 100 | #endif -------------------------------------------------------------------------------- /MyActor/actor/wrapped_try_tick_handler.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRAPPED_TRY_TICK_HANDLER_H 2 | #define __WRAPPED_TRY_TICK_HANDLER_H 3 | 4 | #include "wrapped_capture.h" 5 | 6 | template 7 | class wrapped_try_tick_handler 8 | { 9 | typedef RM_CREF(Handler) handler_type; 10 | public: 11 | wrapped_try_tick_handler(Poster* poster, Handler& handler) 12 | : _poster(poster), 13 | _handler(std::forward(handler)) 14 | { 15 | } 16 | 17 | template 18 | wrapped_try_tick_handler(wrapped_try_tick_handler&& sp) 19 | :_poster(sp._poster), 20 | _handler(std::move(sp._handler)) 21 | { 22 | } 23 | 24 | template 25 | void operator=(wrapped_try_tick_handler&& sp) 26 | { 27 | _poster = sp._poster; 28 | _handler = std::move(sp._handler); 29 | } 30 | 31 | template 32 | void operator()(Args&&... args) 33 | { 34 | _poster->try_tick(wrap_capture(_handler, std::forward(args)...)); 35 | } 36 | 37 | void operator()() 38 | { 39 | _poster->try_tick(_handler); 40 | } 41 | 42 | Poster* _poster; 43 | handler_type _handler; 44 | }; 45 | ////////////////////////////////////////////////////////////////////////// 46 | 47 | template 48 | class wrapped_try_tick_handler 49 | { 50 | typedef RM_CREF(Handler) handler_type; 51 | public: 52 | wrapped_try_tick_handler(Poster* poster, Handler& handler) 53 | : _poster(poster), 54 | _handler(std::forward(handler)) 55 | #if (_DEBUG || DEBUG) 56 | , _checkOnce(std::make_shared>(false)) 57 | #endif 58 | { 59 | } 60 | 61 | template 62 | wrapped_try_tick_handler(wrapped_try_tick_handler&& sd) 63 | :_poster(sd._poster), 64 | _handler(std::move(sd._handler)) 65 | #if (_DEBUG || DEBUG) 66 | , _checkOnce(sd._checkOnce) 67 | #endif 68 | { 69 | } 70 | 71 | template 72 | void operator=(wrapped_try_tick_handler&& sd) 73 | { 74 | _poster = sd._poster; 75 | _handler = std::move(sd._handler); 76 | #if (_DEBUG || DEBUG) 77 | _checkOnce = sd._checkOnce; 78 | #endif 79 | } 80 | 81 | template 82 | void operator()(Args&&... args) 83 | { 84 | assert(!_checkOnce->exchange(true)); 85 | _poster->try_tick(wrap_capture(std::move(_handler), std::forward(args)...)); 86 | } 87 | 88 | void operator()() 89 | { 90 | assert(!_checkOnce->exchange(true)); 91 | _poster->try_tick(std::move(_handler)); 92 | } 93 | 94 | Poster* _poster; 95 | handler_type _handler; 96 | #if (_DEBUG || DEBUG) 97 | std::shared_ptr > _checkOnce; 98 | #endif 99 | }; 100 | 101 | #endif -------------------------------------------------------------------------------- /MyActor/debug.mak: -------------------------------------------------------------------------------- 1 | #Generated by VisualGDB (http://visualgdb.com) 2 | #DO NOT EDIT THIS FILE MANUALLY UNLESS YOU ABSOLUTELY NEED TO 3 | #USE VISUALGDB PROJECT PROPERTIES DIALOG INSTEAD 4 | 5 | BINARYDIR := Debug 6 | 7 | #Toolchain 8 | CC := /usr/gcc-4.9.3/bin/gcc 9 | CXX := /usr/gcc-4.9.3/bin/g++ 10 | LD := $(CXX) 11 | AR := ar 12 | OBJCOPY := objcopy 13 | 14 | #Additional flags 15 | PREPROCESSOR_MACROS := DEBUG _DEBUG ENABLE_NEXT_TICK ENABLE_CHECK_LOST DISABLE_BOOST_TIMER ENABLE_DUMP_STACK 16 | INCLUDE_DIRS := /home/ham/cpplib/boost 17 | LIBRARY_DIRS := /home/ham/cpplib/boost/stage/lib ./actor/lib 18 | LIBRARY_NAMES := pthread rt dl fcontext_x64 boost_thread boost_system boost_chrono 19 | ADDITIONAL_LINKER_INPUTS := 20 | MACOS_FRAMEWORKS := 21 | LINUX_PACKAGES := 22 | 23 | CFLAGS := -ggdb -ffunction-sections -O0 24 | CXXFLAGS := -ggdb -ffunction-sections -O0 -std=c++11 -Wall -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable -Wno-delete-non-virtual-dtor -Wno-strict-aliasing 25 | ASFLAGS := 26 | LDFLAGS := -Wl,-gc-sections 27 | COMMONFLAGS := 28 | 29 | START_GROUP := -Wl,--start-group 30 | END_GROUP := -Wl,--end-group 31 | 32 | #Additional options detected from testing the toolchain 33 | IS_LINUX_PROJECT := 1 34 | -------------------------------------------------------------------------------- /MyActor/release.mak: -------------------------------------------------------------------------------- 1 | #Generated by VisualGDB (http://visualgdb.com) 2 | #DO NOT EDIT THIS FILE MANUALLY UNLESS YOU ABSOLUTELY NEED TO 3 | #USE VISUALGDB PROJECT PROPERTIES DIALOG INSTEAD 4 | 5 | BINARYDIR := Release 6 | 7 | #Toolchain 8 | CC := /usr/gcc-4.9.3/bin/gcc 9 | CXX := /usr/gcc-4.9.3/bin/g++ 10 | LD := $(CXX) 11 | AR := ar 12 | OBJCOPY := objcopy 13 | 14 | #Additional flags 15 | PREPROCESSOR_MACROS := NDEBUG RELEASE ENABLE_NEXT_TICK ENABLE_CHECK_LOST DISABLE_BOOST_TIMER ENABLE_DUMP_STACK 16 | INCLUDE_DIRS := /home/ham/cpplib/boost 17 | LIBRARY_DIRS := /home/ham/cpplib/boost/stage/lib ./actor/lib 18 | LIBRARY_NAMES := pthread rt dl fcontext_x64 boost_thread boost_system boost_chrono 19 | ADDITIONAL_LINKER_INPUTS := 20 | MACOS_FRAMEWORKS := 21 | LINUX_PACKAGES := 22 | 23 | CFLAGS := -ffunction-sections -O2 24 | CXXFLAGS := -ffunction-sections -O2 -fno-rtti -std=c++11 -Wall -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable -Wno-delete-non-virtual-dtor -Wno-strict-aliasing 25 | ASFLAGS := 26 | LDFLAGS := -Wl,-gc-sections 27 | COMMONFLAGS := 28 | 29 | START_GROUP := -Wl,--start-group 30 | END_GROUP := -Wl,--end-group 31 | 32 | #Additional options detected from testing the toolchain 33 | IS_LINUX_PROJECT := 1 34 | -------------------------------------------------------------------------------- /MyActor_arm_linux/Makefile: -------------------------------------------------------------------------------- 1 | #Generated by VisualGDB project wizard. 2 | #Note: VisualGDB will automatically update this file when you add new sources to the project. 3 | #All other changes you make in this file will be preserved. 4 | #Visit http://visualgdb.com/makefiles for more details 5 | 6 | #VisualGDB: AutoSourceFiles #<--- remove this line to disable auto-updating of SOURCEFILES and EXTERNAL_LIBS 7 | 8 | TARGETNAME := MyActor_arm_linux.run 9 | #TARGETTYPE can be APP, STATIC or SHARED 10 | TARGETTYPE := APP 11 | 12 | to_lowercase = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) 13 | 14 | CONFIG ?= DEBUG 15 | 16 | CONFIGURATION_FLAGS_FILE := $(call to_lowercase,$(CONFIG)).mak 17 | 18 | include $(CONFIGURATION_FLAGS_FILE) 19 | include $(ADDITIONAL_MAKE_FILES) 20 | 21 | ifeq ($(BINARYDIR),) 22 | error: 23 | $(error Invalid configuration, please check your inputs) 24 | endif 25 | 26 | SOURCEFILES := ../MyActor/actor.cpp ../MyActor/MyActor.cpp 27 | EXTERNAL_LIBS := 28 | EXTERNAL_LIBS_COPIED := $(foreach lib, $(EXTERNAL_LIBS),$(BINARYDIR)/$(notdir $(lib))) 29 | 30 | CFLAGS += $(COMMONFLAGS) 31 | CXXFLAGS += $(COMMONFLAGS) 32 | ASFLAGS += $(COMMONFLAGS) 33 | LDFLAGS += $(COMMONFLAGS) 34 | 35 | CFLAGS += $(addprefix -I,$(INCLUDE_DIRS)) 36 | CXXFLAGS += $(addprefix -I,$(INCLUDE_DIRS)) 37 | 38 | CFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS)) 39 | CXXFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS)) 40 | ASFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS)) 41 | 42 | CXXFLAGS += $(addprefix -framework ,$(MACOS_FRAMEWORKS)) 43 | CFLAGS += $(addprefix -framework ,$(MACOS_FRAMEWORKS)) 44 | LDFLAGS += $(addprefix -framework ,$(MACOS_FRAMEWORKS)) 45 | 46 | LDFLAGS += $(addprefix -L,$(LIBRARY_DIRS)) 47 | 48 | ifeq ($(GENERATE_MAP_FILE),1) 49 | LDFLAGS += -Wl,-Map=$(BINARYDIR)/$(basename $(TARGETNAME)).map 50 | endif 51 | 52 | LIBRARY_LDFLAGS = $(addprefix -l,$(LIBRARY_NAMES)) 53 | 54 | ifeq ($(IS_LINUX_PROJECT),1) 55 | RPATH_PREFIX := -Wl,--rpath='$$ORIGIN/../ 56 | LIBRARY_LDFLAGS += $(EXTERNAL_LIBS) 57 | LIBRARY_LDFLAGS += -Wl,--rpath='$$ORIGIN' 58 | LIBRARY_LDFLAGS += $(addsuffix ',$(addprefix $(RPATH_PREFIX),$(dir $(EXTERNAL_LIBS)))) 59 | 60 | ifeq ($(TARGETTYPE),SHARED) 61 | CFLAGS += -fPIC 62 | CXXFLAGS += -fPIC 63 | ASFLAGS += -fPIC 64 | LIBRARY_LDFLAGS += -Wl,-soname,$(TARGETNAME) 65 | endif 66 | 67 | ifneq ($(LINUX_PACKAGES),) 68 | PACKAGE_CFLAGS := $(foreach pkg,$(LINUX_PACKAGES),$(shell pkg-config --cflags $(pkg))) 69 | PACKAGE_LDFLAGS := $(foreach pkg,$(LINUX_PACKAGES),$(shell pkg-config --libs $(pkg))) 70 | CFLAGS += $(PACKAGE_CFLAGS) 71 | CXXFLAGS += $(PACKAGE_CFLAGS) 72 | LIBRARY_LDFLAGS += $(PACKAGE_LDFLAGS) 73 | endif 74 | else 75 | LIBRARY_LDFLAGS += $(EXTERNAL_LIBS) 76 | endif 77 | 78 | LIBRARY_LDFLAGS += $(ADDITIONAL_LINKER_INPUTS) 79 | 80 | all_make_files := $(firstword $(MAKEFILE_LIST)) $(CONFIGURATION_FLAGS_FILE) $(ADDITIONAL_MAKE_FILES) 81 | 82 | ifeq ($(STARTUPFILES),) 83 | all_source_files := $(SOURCEFILES) 84 | else 85 | all_source_files := $(STARTUPFILES) $(filter-out $(STARTUPFILES),$(SOURCEFILES)) 86 | endif 87 | 88 | source_obj1 := $(all_source_files:.cpp=.o) 89 | source_obj2 := $(source_obj1:.c=.o) 90 | source_obj3 := $(source_obj2:.s=.o) 91 | source_obj4 := $(source_obj3:.S=.o) 92 | source_obj5 := $(source_obj4:.cc=.o) 93 | source_objs := $(source_obj5:.cxx=.o) 94 | 95 | all_objs := $(addprefix $(BINARYDIR)/, $(notdir $(source_objs))) 96 | 97 | PRIMARY_OUTPUTS := 98 | 99 | ifeq ($(GENERATE_BIN_FILE),1) 100 | PRIMARY_OUTPUTS += $(BINARYDIR)/$(basename $(TARGETNAME)).bin 101 | endif 102 | 103 | ifeq ($(GENERATE_IHEX_FILE),1) 104 | PRIMARY_OUTPUTS += $(BINARYDIR)/$(basename $(TARGETNAME)).ihex 105 | endif 106 | 107 | ifeq ($(PRIMARY_OUTPUTS),) 108 | PRIMARY_OUTPUTS := $(BINARYDIR)/$(TARGETNAME) 109 | endif 110 | 111 | all: $(PRIMARY_OUTPUTS) 112 | 113 | $(BINARYDIR)/$(basename $(TARGETNAME)).bin: $(BINARYDIR)/$(TARGETNAME) 114 | $(OBJCOPY) -O binary $< $@ 115 | 116 | $(BINARYDIR)/$(basename $(TARGETNAME)).ihex: $(BINARYDIR)/$(TARGETNAME) 117 | $(OBJCOPY) -O ihex $< $@ 118 | 119 | ifeq ($(TARGETTYPE),APP) 120 | $(BINARYDIR)/$(TARGETNAME): $(all_objs) $(EXTERNAL_LIBS) 121 | $(LD) -o $@ $(LDFLAGS) $(START_GROUP) $(all_objs) $(LIBRARY_LDFLAGS) $(END_GROUP) 122 | endif 123 | 124 | ifeq ($(TARGETTYPE),SHARED) 125 | $(BINARYDIR)/$(TARGETNAME): $(all_objs) $(EXTERNAL_LIBS) 126 | $(LD) -shared -o $@ $(LDFLAGS) $(START_GROUP) $(all_objs) $(LIBRARY_LDFLAGS) $(END_GROUP) 127 | endif 128 | 129 | ifeq ($(TARGETTYPE),STATIC) 130 | $(BINARYDIR)/$(TARGETNAME): $(all_objs) 131 | $(AR) -r $@ $^ 132 | endif 133 | 134 | -include $(all_objs:.o=.dep) 135 | 136 | clean: 137 | ifeq ($(USE_DEL_TO_CLEAN),1) 138 | del /S /Q $(BINARYDIR) 139 | else 140 | rm -rf $(BINARYDIR) 141 | endif 142 | 143 | $(BINARYDIR): 144 | mkdir $(BINARYDIR) 145 | 146 | #VisualGDB: FileSpecificTemplates #<--- VisualGDB will use the following lines to define rules for source files in subdirectories 147 | $(BINARYDIR)/%.o : %.cpp $(all_make_files) |$(BINARYDIR) 148 | $(CXX) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 149 | 150 | $(BINARYDIR)/%.o : %.c $(all_make_files) |$(BINARYDIR) 151 | $(CC) $(CFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 152 | 153 | $(BINARYDIR)/%.o : %.S $(all_make_files) |$(BINARYDIR) 154 | $(CC) $(CFLAGS) $(ASFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 155 | 156 | $(BINARYDIR)/%.o : %.s $(all_make_files) |$(BINARYDIR) 157 | $(CC) $(CFLAGS) $(ASFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 158 | 159 | $(BINARYDIR)/%.o : %.cc $(all_make_files) |$(BINARYDIR) 160 | $(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 161 | 162 | $(BINARYDIR)/%.o : %.cxx $(all_make_files) |$(BINARYDIR) 163 | $(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 164 | 165 | #VisualGDB: GeneratedRules #<--- All lines below are auto-generated 166 | 167 | 168 | $(BINARYDIR)/actor.o : ../MyActor/actor.cpp $(all_make_files) |$(BINARYDIR) 169 | $(CXX) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 170 | 171 | 172 | $(BINARYDIR)/MyActor.o : ../MyActor/MyActor.cpp $(all_make_files) |$(BINARYDIR) 173 | $(CXX) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 174 | 175 | -------------------------------------------------------------------------------- /MyActor_arm_linux/MyActor_arm_linux-Debug.vgdbsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | Debug 4 | 5 | 6 | 7 | RemoteUnix 8 | 9 | 10 | None 11 | 12 | 13 | 192.168.0.108 14 | SSH 15 | pi 16 | 17 | 18 | false 19 | 20 | None 21 | 22 | $(ProjectDir) 23 | /tmp/VisualGDB/$(ProjectDirUnixStyle) 24 | 25 | *.cpp 26 | *.h 27 | *.c 28 | *.cc 29 | *.cxx 30 | *.mak 31 | Makefile 32 | 33 | true 34 | true 35 | 36 | 37 | false 38 | false 39 | false 40 | false 41 | 42 | 43 | Makefile 44 | Debug 45 | -j2 46 | 47 | arm-linux-gnueabihf 48 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin 49 | false 50 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin\arm-linux-gnueabihf-gcc.exe 51 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin\arm-linux-gnueabihf-g++.exe 52 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin\arm-linux-gnueabihf-gdb.exe 53 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin\arm-linux-gnueabihf-ar.exe 54 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin\arm-linux-gnueabihf-objcopy.exe 55 | $(VISUALGDB_DIR)\make.exe 56 | 57 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin 58 | 59 | true 60 | false 61 | 62 | 63 | RemoteUnix 64 | 65 | 66 | 67 | false 68 | 69 | None 70 | 71 | cmd.exe 72 | /c "$(VISUALGDB_DIR)\make.exe" 73 | $(BuildDir) 74 | 75 | 76 | 77 | LANG 78 | en_US.UTF-8 79 | 80 | 81 | PATH 82 | %PATH%;D:\cpplib\arm-linux-gnueabihf-gcc49\bin 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | false 92 | false 93 | true 94 | false 95 | false 96 | false 97 | false 98 | true 99 | false 100 | None 101 | 102 | false 103 | false 104 | false 105 | false 106 | false 107 | false 108 | false 109 | false 110 | 111 | false 112 | false 113 | main 114 | true 115 | false 116 | false 117 | 118 | 119 | $(TargetPath) 120 | 2000 121 | 122 | 123 | false 124 | /tmp/VisualGDB/$(ProjectDirUnixStyle)/$(ConfigurationName)/MyActor_arm_linux.run 125 | Disabled 126 | false 127 | false 128 | true 129 | 130 | true 131 | 132 | 133 | 134 | 135 | 136 | false 137 | 138 | 192.168.0.108 139 | SSH 140 | pi 141 | 142 | $(ProjectDir) 143 | /tmp/VisualGDB/$(ProjectDirUnixStyle) 144 | 145 | *.run 146 | 147 | true 148 | true 149 | 150 | Debug 151 | 152 | 153 | 154 | false 155 | 156 | 192.168.0.108 157 | SSH 158 | pi 159 | 160 | chmod 161 | +x $(TargetFileName) 162 | $(DeployDir) 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | Default 175 | 176 | 177 | 178 | true 179 | 180 | 181 | -------------------------------------------------------------------------------- /MyActor_arm_linux/MyActor_arm_linux-Release.vgdbsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | Release 4 | 5 | 6 | 7 | RemoteUnix 8 | 9 | 10 | None 11 | 12 | 13 | 192.168.0.108 14 | SSH 15 | pi 16 | 17 | 18 | false 19 | 20 | None 21 | 22 | $(ProjectDir) 23 | /tmp/VisualGDB/$(ProjectDirUnixStyle) 24 | 25 | *.cpp 26 | *.h 27 | *.c 28 | *.cc 29 | *.cxx 30 | *.mak 31 | Makefile 32 | 33 | true 34 | true 35 | 36 | 37 | false 38 | false 39 | false 40 | false 41 | 42 | 43 | Makefile 44 | Release 45 | -j2 46 | 47 | arm-linux-gnueabihf 48 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin 49 | false 50 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin\arm-linux-gnueabihf-gcc.exe 51 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin\arm-linux-gnueabihf-g++.exe 52 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin\arm-linux-gnueabihf-gdb.exe 53 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin\arm-linux-gnueabihf-ar.exe 54 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin\arm-linux-gnueabihf-objcopy.exe 55 | $(VISUALGDB_DIR)\make.exe 56 | 57 | D:\cpplib\arm-linux-gnueabihf-gcc49\bin 58 | 59 | true 60 | false 61 | 62 | 63 | RemoteUnix 64 | 65 | 66 | 67 | false 68 | 69 | None 70 | 71 | cmd.exe 72 | /c "$(VISUALGDB_DIR)\make.exe" 73 | $(BuildDir) 74 | 75 | 76 | 77 | LANG 78 | en_US.UTF-8 79 | 80 | 81 | PATH 82 | %PATH%;D:\cpplib\arm-linux-gnueabihf-gcc49\bin 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | false 92 | false 93 | true 94 | false 95 | false 96 | false 97 | false 98 | true 99 | false 100 | None 101 | 102 | false 103 | false 104 | false 105 | false 106 | false 107 | false 108 | false 109 | false 110 | 111 | false 112 | false 113 | main 114 | true 115 | false 116 | false 117 | 118 | 119 | $(TargetPath) 120 | 2000 121 | 122 | 123 | false 124 | /tmp/VisualGDB/$(ProjectDirUnixStyle)/$(ConfigurationName)/MyActor_arm_linux.run 125 | Disabled 126 | false 127 | false 128 | true 129 | 130 | true 131 | 132 | 133 | 134 | 135 | 136 | false 137 | 138 | 192.168.0.108 139 | SSH 140 | pi 141 | 142 | $(ProjectDir) 143 | /tmp/VisualGDB/$(ProjectDirUnixStyle) 144 | 145 | *.run 146 | 147 | true 148 | true 149 | 150 | Release 151 | 152 | 153 | 154 | false 155 | 156 | 192.168.0.108 157 | SSH 158 | pi 159 | 160 | chmod 161 | +x $(TargetFileName) 162 | $(DeployDir) 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | Default 175 | 176 | 177 | 178 | true 179 | 180 | 181 | -------------------------------------------------------------------------------- /MyActor_arm_linux/MyActor_arm_linux.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {5B0AE8CB-4AAA-435D-9CAC-C20F1CCCFC6A} 15 | 16 | 17 | 18 | Makefile 19 | true 20 | v120 21 | 22 | 23 | Makefile 24 | false 25 | v120 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | D:\cpplib\boost;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\include\c++\4.9.3;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\include\c++\4.9.3\arm-linux-gnueabihf;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\include\c++\4.9.3\backward;d:\cpplib\arm-linux-gnueabihf-gcc49\lib\gcc\arm-linux-gnueabihf\4.9.3\include;d:\cpplib\arm-linux-gnueabihf-gcc49\lib\gcc\arm-linux-gnueabihf\4.9.3\include-fixed;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\include;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\libc\usr\include;D:\cpplib\boost;d:\cpplib\gcc-linaro-arm-linux-gnueabihf-4.8-2014.04\arm-linux-gnueabihf\include\c++\4.8.3;d:\cpplib\gcc-linaro-arm-linux-gnueabihf-4.8-2014.04\arm-linux-gnueabihf\include\c++\4.8.3\arm-linux-gnueabihf;d:\cpplib\gcc-linaro-arm-linux-gnueabihf-4.8-2014.04\arm-linux-gnueabihf\include\c++\4.8.3\backward;d:\cpplib\gcc-linaro-arm-linux-gnueabihf-4.8-2014.04\lib\gcc\arm-linux-gnueabihf\4.8.3\include;d:\cpplib\gcc-linaro-arm-linux-gnueabihf-4.8-2014.04\lib\gcc\arm-linux-gnueabihf\4.8.3\include-fixed;d:\cpplib\gcc-linaro-arm-linux-gnueabihf-4.8-2014.04\arm-linux-gnueabihf\include;d:\cpplib\gcc-linaro-arm-linux-gnueabihf-4.8-2014.04\arm-linux-gnueabihf\libc\usr\include;D:\cpplib\boost;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\include\c++\4.9.3;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\include\c++\4.9.3\arm-linux-gnueabihf;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\include\c++\4.9.3\backward;d:\cpplib\arm-linux-gnueabihf-gcc49\lib\gcc\arm-linux-gnueabihf\4.9.3\include;d:\cpplib\arm-linux-gnueabihf-gcc49\lib\gcc\arm-linux-gnueabihf\4.9.3\include-fixed;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\include;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\libc\usr\include;$(NMakeIncludeSearchPath) 39 | $(ProjectDir)\gcc_Debug.h;$(VISUALGDB_DIR)\gcc_compat.h;$(NMakeForcedIncludes) 40 | "$(VISUALGDB_DIR)\VisualGDB.exe" /build "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 41 | "$(VISUALGDB_DIR)\VisualGDB.exe" /clean "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 42 | "$(VISUALGDB_DIR)\VisualGDB.exe" /rebuild "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 43 | $(ProjectDir)MyActor_arm_linux-Debug.vgdbsettings 44 | 45 | 46 | 47 | __VisualGDB_CFG_Debug;$(NMakePreprocessorDefinitions) 48 | 49 | 50 | D:\cpplib\boost;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\include\c++\4.9.3;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\include\c++\4.9.3\arm-linux-gnueabihf;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\include\c++\4.9.3\backward;d:\cpplib\arm-linux-gnueabihf-gcc49\lib\gcc\arm-linux-gnueabihf\4.9.3\include;d:\cpplib\arm-linux-gnueabihf-gcc49\lib\gcc\arm-linux-gnueabihf\4.9.3\include-fixed;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\include;d:\cpplib\arm-linux-gnueabihf-gcc49\arm-linux-gnueabihf\libc\usr\include;$(NMakeIncludeSearchPath) 51 | $(ProjectDir)\gcc_Release.h;$(VISUALGDB_DIR)\gcc_compat.h;$(NMakeForcedIncludes) 52 | "$(VISUALGDB_DIR)\VisualGDB.exe" /build "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 53 | "$(VISUALGDB_DIR)\VisualGDB.exe" /clean "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 54 | "$(VISUALGDB_DIR)\VisualGDB.exe" /rebuild "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 55 | $(ProjectDir)MyActor_arm_linux-Release.vgdbsettings 56 | 57 | 58 | 59 | __VisualGDB_CFG_Release;$(NMakePreprocessorDefinitions) 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /MyActor_arm_linux/MyActor_arm_linux.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {0a3575f3-4019-4bca-89e7-35527bf19c0e} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {4fc4da5f-32c0-425c-a2a5-af9d75105066} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {c4881152-e0e5-4906-becd-d72bc8bc8541} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | {aff2c2f1-9f6e-4a19-8246-36267698626f} 18 | *.mak 19 | 20 | 21 | 22 | 23 | 24 | Make files 25 | 26 | 27 | Make files 28 | 29 | 30 | 31 | 32 | Source files 33 | 34 | 35 | Source files 36 | 37 | 38 | -------------------------------------------------------------------------------- /MyActor_arm_linux/debug.mak: -------------------------------------------------------------------------------- 1 | #Generated by VisualGDB (http://visualgdb.com) 2 | #DO NOT EDIT THIS FILE MANUALLY UNLESS YOU ABSOLUTELY NEED TO 3 | #USE VISUALGDB PROJECT PROPERTIES DIALOG INSTEAD 4 | 5 | BINARYDIR := Debug 6 | 7 | #Toolchain 8 | CC := D:/cpplib/arm-linux-gnueabihf-gcc49/bin/arm-linux-gnueabihf-gcc.exe 9 | CXX := D:/cpplib/arm-linux-gnueabihf-gcc49/bin/arm-linux-gnueabihf-g++.exe 10 | LD := $(CXX) 11 | AR := D:/cpplib/arm-linux-gnueabihf-gcc49/bin/arm-linux-gnueabihf-ar.exe 12 | OBJCOPY := D:/cpplib/arm-linux-gnueabihf-gcc49/bin/arm-linux-gnueabihf-objcopy.exe 13 | 14 | #Additional flags 15 | PREPROCESSOR_MACROS := DEBUG _ARM32 _DEBUG ENABLE_NEXT_TICK ENABLE_CHECK_LOST DISABLE_BOOST_TIMER ENABLE_DUMP_STACK 16 | INCLUDE_DIRS := D:\cpplib\boost 17 | LIBRARY_DIRS := D:\cpplib\boost\lib_armhf-linux-gcc492 ../MyActor/actor/lib 18 | LIBRARY_NAMES := pthread fcontext_armhf32 boost_thread boost_system boost_chrono 19 | ADDITIONAL_LINKER_INPUTS := 20 | MACOS_FRAMEWORKS := 21 | LINUX_PACKAGES := 22 | 23 | CFLAGS := -ggdb -ffunction-sections -O0 24 | CXXFLAGS := -ggdb -ffunction-sections -O0 -std=c++11 -Wall -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable -Wno-delete-non-virtual-dtor -Wno-strict-aliasing 25 | ASFLAGS := 26 | LDFLAGS := -Wl,-gc-sections 27 | COMMONFLAGS := 28 | 29 | START_GROUP := -Wl,--start-group 30 | END_GROUP := -Wl,--end-group 31 | 32 | #Additional options detected from testing the toolchain 33 | USE_DEL_TO_CLEAN := 1 34 | CP_NOT_AVAILABLE := 1 35 | IS_LINUX_PROJECT := 1 36 | -------------------------------------------------------------------------------- /MyActor_arm_linux/release.mak: -------------------------------------------------------------------------------- 1 | #Generated by VisualGDB (http://visualgdb.com) 2 | #DO NOT EDIT THIS FILE MANUALLY UNLESS YOU ABSOLUTELY NEED TO 3 | #USE VISUALGDB PROJECT PROPERTIES DIALOG INSTEAD 4 | 5 | BINARYDIR := Release 6 | 7 | #Toolchain 8 | CC := D:/cpplib/arm-linux-gnueabihf-gcc49/bin/arm-linux-gnueabihf-gcc.exe 9 | CXX := D:/cpplib/arm-linux-gnueabihf-gcc49/bin/arm-linux-gnueabihf-g++.exe 10 | LD := $(CXX) 11 | AR := D:/cpplib/arm-linux-gnueabihf-gcc49/bin/arm-linux-gnueabihf-ar.exe 12 | OBJCOPY := D:/cpplib/arm-linux-gnueabihf-gcc49/bin/arm-linux-gnueabihf-objcopy.exe 13 | 14 | #Additional flags 15 | PREPROCESSOR_MACROS := NDEBUG _ARM32 RELEASE ENABLE_NEXT_TICK ENABLE_CHECK_LOST DISABLE_BOOST_TIMER 16 | INCLUDE_DIRS := D:\cpplib\boost 17 | LIBRARY_DIRS := D:\cpplib\boost\lib_armhf-linux-gcc492 ../MyActor/actor/lib 18 | LIBRARY_NAMES := pthread fcontext_armhf32 boost_thread boost_system boost_chrono 19 | ADDITIONAL_LINKER_INPUTS := 20 | MACOS_FRAMEWORKS := 21 | LINUX_PACKAGES := 22 | 23 | CFLAGS := -ffunction-sections -O2 24 | CXXFLAGS := -ffunction-sections -O2 -fno-rtti -std=c++11 -Wall -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable -Wno-delete-non-virtual-dtor -Wno-strict-aliasing 25 | ASFLAGS := 26 | LDFLAGS := -Wl,-gc-sections 27 | COMMONFLAGS := 28 | 29 | START_GROUP := -Wl,--start-group 30 | END_GROUP := -Wl,--end-group 31 | 32 | #Additional options detected from testing the toolchain 33 | USE_DEL_TO_CLEAN := 1 34 | CP_NOT_AVAILABLE := 1 35 | IS_LINUX_PROJECT := 1 36 | -------------------------------------------------------------------------------- /MyActor_mingw/Makefile: -------------------------------------------------------------------------------- 1 | #Generated by VisualGDB project wizard. 2 | #Note: VisualGDB will automatically update this file when you add new sources to the project. 3 | #All other changes you make in this file will be preserved. 4 | #Visit http://visualgdb.com/makefiles for more details 5 | 6 | #VisualGDB: AutoSourceFiles #<--- remove this line to disable auto-updating of SOURCEFILES and EXTERNAL_LIBS 7 | 8 | TARGETNAME := MyActor_mingw.exe 9 | #TARGETTYPE can be APP, STATIC or SHARED 10 | TARGETTYPE := APP 11 | 12 | to_lowercase = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) 13 | 14 | CONFIG ?= DEBUG 15 | 16 | CONFIGURATION_FLAGS_FILE := $(call to_lowercase,$(CONFIG)).mak 17 | 18 | include $(CONFIGURATION_FLAGS_FILE) 19 | include $(ADDITIONAL_MAKE_FILES) 20 | 21 | ifeq ($(BINARYDIR),) 22 | error: 23 | $(error Invalid configuration, please check your inputs) 24 | endif 25 | 26 | SOURCEFILES := ../MyActor/actor.cpp ../MyActor/MyActor.cpp 27 | EXTERNAL_LIBS := 28 | EXTERNAL_LIBS_COPIED := $(foreach lib, $(EXTERNAL_LIBS),$(BINARYDIR)/$(notdir $(lib))) 29 | 30 | CFLAGS += $(COMMONFLAGS) 31 | CXXFLAGS += $(COMMONFLAGS) 32 | ASFLAGS += $(COMMONFLAGS) 33 | LDFLAGS += $(COMMONFLAGS) 34 | 35 | CFLAGS += $(addprefix -I,$(INCLUDE_DIRS)) 36 | CXXFLAGS += $(addprefix -I,$(INCLUDE_DIRS)) 37 | 38 | CFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS)) 39 | CXXFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS)) 40 | ASFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS)) 41 | 42 | CXXFLAGS += $(addprefix -framework ,$(MACOS_FRAMEWORKS)) 43 | CFLAGS += $(addprefix -framework ,$(MACOS_FRAMEWORKS)) 44 | LDFLAGS += $(addprefix -framework ,$(MACOS_FRAMEWORKS)) 45 | 46 | LDFLAGS += $(addprefix -L,$(LIBRARY_DIRS)) 47 | 48 | ifeq ($(GENERATE_MAP_FILE),1) 49 | LDFLAGS += -Wl,-Map=$(BINARYDIR)/$(basename $(TARGETNAME)).map 50 | endif 51 | 52 | LIBRARY_LDFLAGS = $(addprefix -l,$(LIBRARY_NAMES)) 53 | 54 | ifeq ($(IS_LINUX_PROJECT),1) 55 | RPATH_PREFIX := -Wl,--rpath='$$ORIGIN/../ 56 | LIBRARY_LDFLAGS += $(EXTERNAL_LIBS) 57 | LIBRARY_LDFLAGS += -Wl,--rpath='$$ORIGIN' 58 | LIBRARY_LDFLAGS += $(addsuffix ',$(addprefix $(RPATH_PREFIX),$(dir $(EXTERNAL_LIBS)))) 59 | 60 | ifeq ($(TARGETTYPE),SHARED) 61 | CFLAGS += -fPIC 62 | CXXFLAGS += -fPIC 63 | ASFLAGS += -fPIC 64 | LIBRARY_LDFLAGS += -Wl,-soname,$(TARGETNAME) 65 | endif 66 | 67 | ifneq ($(LINUX_PACKAGES),) 68 | PACKAGE_CFLAGS := $(foreach pkg,$(LINUX_PACKAGES),$(shell pkg-config --cflags $(pkg))) 69 | PACKAGE_LDFLAGS := $(foreach pkg,$(LINUX_PACKAGES),$(shell pkg-config --libs $(pkg))) 70 | CFLAGS += $(PACKAGE_CFLAGS) 71 | CXXFLAGS += $(PACKAGE_CFLAGS) 72 | LIBRARY_LDFLAGS += $(PACKAGE_LDFLAGS) 73 | endif 74 | else 75 | LIBRARY_LDFLAGS += $(EXTERNAL_LIBS) 76 | endif 77 | 78 | LIBRARY_LDFLAGS += $(ADDITIONAL_LINKER_INPUTS) 79 | 80 | all_make_files := $(firstword $(MAKEFILE_LIST)) $(CONFIGURATION_FLAGS_FILE) $(ADDITIONAL_MAKE_FILES) 81 | 82 | ifeq ($(STARTUPFILES),) 83 | all_source_files := $(SOURCEFILES) 84 | else 85 | all_source_files := $(STARTUPFILES) $(filter-out $(STARTUPFILES),$(SOURCEFILES)) 86 | endif 87 | 88 | source_obj1 := $(all_source_files:.cpp=.o) 89 | source_obj2 := $(source_obj1:.c=.o) 90 | source_obj3 := $(source_obj2:.s=.o) 91 | source_obj4 := $(source_obj3:.S=.o) 92 | source_obj5 := $(source_obj4:.cc=.o) 93 | source_objs := $(source_obj5:.cxx=.o) 94 | 95 | all_objs := $(addprefix $(BINARYDIR)/, $(notdir $(source_objs))) 96 | 97 | PRIMARY_OUTPUTS := 98 | 99 | ifeq ($(GENERATE_BIN_FILE),1) 100 | PRIMARY_OUTPUTS += $(BINARYDIR)/$(basename $(TARGETNAME)).bin 101 | endif 102 | 103 | ifeq ($(GENERATE_IHEX_FILE),1) 104 | PRIMARY_OUTPUTS += $(BINARYDIR)/$(basename $(TARGETNAME)).ihex 105 | endif 106 | 107 | ifeq ($(PRIMARY_OUTPUTS),) 108 | PRIMARY_OUTPUTS := $(BINARYDIR)/$(TARGETNAME) 109 | endif 110 | 111 | all: $(PRIMARY_OUTPUTS) 112 | 113 | $(BINARYDIR)/$(basename $(TARGETNAME)).bin: $(BINARYDIR)/$(TARGETNAME) 114 | $(OBJCOPY) -O binary $< $@ 115 | 116 | $(BINARYDIR)/$(basename $(TARGETNAME)).ihex: $(BINARYDIR)/$(TARGETNAME) 117 | $(OBJCOPY) -O ihex $< $@ 118 | 119 | ifeq ($(TARGETTYPE),APP) 120 | $(BINARYDIR)/$(TARGETNAME): $(all_objs) $(EXTERNAL_LIBS) 121 | $(LD) -o $@ $(LDFLAGS) $(START_GROUP) $(all_objs) $(LIBRARY_LDFLAGS) $(END_GROUP) 122 | endif 123 | 124 | ifeq ($(TARGETTYPE),SHARED) 125 | $(BINARYDIR)/$(TARGETNAME): $(all_objs) $(EXTERNAL_LIBS) 126 | $(LD) -shared -o $@ $(LDFLAGS) $(START_GROUP) $(all_objs) $(LIBRARY_LDFLAGS) $(END_GROUP) 127 | endif 128 | 129 | ifeq ($(TARGETTYPE),STATIC) 130 | $(BINARYDIR)/$(TARGETNAME): $(all_objs) 131 | $(AR) -r $@ $^ 132 | endif 133 | 134 | -include $(all_objs:.o=.dep) 135 | 136 | clean: 137 | ifeq ($(USE_DEL_TO_CLEAN),1) 138 | del /S /Q $(BINARYDIR) 139 | else 140 | rm -rf $(BINARYDIR) 141 | endif 142 | 143 | $(BINARYDIR): 144 | mkdir $(BINARYDIR) 145 | 146 | #VisualGDB: FileSpecificTemplates #<--- VisualGDB will use the following lines to define rules for source files in subdirectories 147 | $(BINARYDIR)/%.o : %.cpp $(all_make_files) |$(BINARYDIR) 148 | $(CXX) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 149 | 150 | $(BINARYDIR)/%.o : %.c $(all_make_files) |$(BINARYDIR) 151 | $(CC) $(CFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 152 | 153 | $(BINARYDIR)/%.o : %.S $(all_make_files) |$(BINARYDIR) 154 | $(CC) $(CFLAGS) $(ASFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 155 | 156 | $(BINARYDIR)/%.o : %.s $(all_make_files) |$(BINARYDIR) 157 | $(CC) $(CFLAGS) $(ASFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 158 | 159 | $(BINARYDIR)/%.o : %.cc $(all_make_files) |$(BINARYDIR) 160 | $(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 161 | 162 | $(BINARYDIR)/%.o : %.cxx $(all_make_files) |$(BINARYDIR) 163 | $(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 164 | 165 | #VisualGDB: GeneratedRules #<--- All lines below are auto-generated 166 | 167 | 168 | $(BINARYDIR)/actor.o : ../MyActor/actor.cpp $(all_make_files) |$(BINARYDIR) 169 | $(CXX) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 170 | 171 | 172 | $(BINARYDIR)/MyActor.o : ../MyActor/MyActor.cpp $(all_make_files) |$(BINARYDIR) 173 | $(CXX) $(CXXFLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep) 174 | 175 | -------------------------------------------------------------------------------- /MyActor_mingw/MyActor_mingw-Debug.vgdbsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | Debug 4 | 5 | 6 | 7 | 8 | /mingw 9 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64 10 | 11 | 12 | MinGWUnixSlash 13 | 14 | $(ProjectDir) 15 | 16 | 17 | Makefile 18 | Debug 19 | -j2 20 | 21 | MinGW 22 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64 23 | false 24 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin\gcc.exe 25 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin\g++.exe 26 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin\gdb.exe 27 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin\ar.exe 28 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin\mingw32-make.exe 29 | 30 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin 31 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\msys\1.0\bin 32 | 33 | true 34 | false 35 | http://visualgdb.com/toolchains/MinGW 36 | 37 | 38 | 39 | /mingw 40 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64 41 | 42 | 43 | MinGWUnixSlash 44 | 45 | 46 | 47 | false 48 | cmd.exe 49 | /c "C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin\mingw32-make.exe" 50 | $(BuildDir) 51 | 52 | 53 | 54 | LANG 55 | en_US.UTF-8 56 | 57 | 58 | PATH 59 | %PATH%;C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin;C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\msys\1.0\bin 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | false 69 | false 70 | true 71 | false 72 | false 73 | false 74 | false 75 | true 76 | false 77 | None 78 | 79 | false 80 | false 81 | false 82 | false 83 | false 84 | false 85 | false 86 | false 87 | 88 | false 89 | false 90 | main 91 | true 92 | false 93 | false 94 | 95 | 96 | 97 | 98 | 99 | LANG 100 | en_US.UTF-8 101 | 102 | 103 | PATH 104 | %PATH%;E:\cpplib\mingw-w64\x86_64-4.9.2-posix-seh-rt_v3-rev1\mingw64\bin;E:\cpplib\mingw-w64\x86_64-4.9.2-posix-seh-rt_v3-rev1\mingw64\msys\1.0\bin 105 | 106 | 107 | 108 | $(TargetPath) 109 | 2000 110 | 111 | 112 | false 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | Default 124 | 125 | 126 | 127 | true 128 | 129 | 130 | -------------------------------------------------------------------------------- /MyActor_mingw/MyActor_mingw-Release.vgdbsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | Release 4 | 5 | 6 | 7 | 8 | /mingw 9 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64 10 | 11 | 12 | MinGWUnixSlash 13 | 14 | $(ProjectDir) 15 | 16 | 17 | Makefile 18 | Release 19 | -j2 20 | 21 | MinGW 22 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64 23 | false 24 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin\gcc.exe 25 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin\g++.exe 26 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin\gdb.exe 27 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin\ar.exe 28 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin\mingw32-make.exe 29 | 30 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin 31 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\msys\1.0\bin 32 | 33 | true 34 | false 35 | http://visualgdb.com/toolchains/MinGW 36 | 37 | 38 | 39 | /mingw 40 | C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64 41 | 42 | 43 | MinGWUnixSlash 44 | 45 | 46 | 47 | false 48 | cmd.exe 49 | /c "C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin\mingw32-make.exe" 50 | $(BuildDir) 51 | 52 | 53 | 54 | LANG 55 | en_US.UTF-8 56 | 57 | 58 | PATH 59 | %PATH%;C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\bin;C:\mingw64\x86_64-4.9.3-release-posix-seh-rt_v4-rev1\mingw64\msys\1.0\bin 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | false 69 | false 70 | true 71 | false 72 | false 73 | false 74 | false 75 | true 76 | false 77 | None 78 | 79 | false 80 | false 81 | false 82 | false 83 | false 84 | false 85 | false 86 | false 87 | 88 | false 89 | false 90 | main 91 | true 92 | false 93 | false 94 | 95 | 96 | 97 | 98 | 99 | LANG 100 | en_US.UTF-8 101 | 102 | 103 | PATH 104 | %PATH%;E:\cpplib\mingw-w64\x86_64-4.9.2-posix-seh-rt_v3-rev1\mingw64\bin;E:\cpplib\mingw-w64\x86_64-4.9.2-posix-seh-rt_v3-rev1\mingw64\msys\1.0\bin 105 | 106 | 107 | 108 | $(TargetPath) 109 | 2000 110 | 111 | 112 | false 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | Default 124 | 125 | 126 | 127 | true 128 | 129 | 130 | -------------------------------------------------------------------------------- /MyActor_mingw/MyActor_mingw.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {27FDE187-1B88-4A88-BED2-5B8FFCD4C0D0} 15 | 16 | 17 | 18 | Makefile 19 | true 20 | v120 21 | 22 | 23 | Makefile 24 | false 25 | v120 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | $(NMakeIncludeSearchPath) 39 | $(ProjectDir)\gcc_Debug.h;$(VISUALGDB_DIR)\gcc_compat.h;$(NMakeForcedIncludes) 40 | "$(VISUALGDB_DIR)\VisualGDB.exe" /build "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 41 | "$(VISUALGDB_DIR)\VisualGDB.exe" /clean "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 42 | "$(VISUALGDB_DIR)\VisualGDB.exe" /rebuild "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 43 | $(ProjectDir)MyActor_mingw-Debug.vgdbsettings 44 | 45 | 46 | 47 | __VisualGDB_CFG_Debug;$(NMakePreprocessorDefinitions) 48 | 49 | 50 | $(NMakeIncludeSearchPath) 51 | $(ProjectDir)\gcc_Release.h;$(VISUALGDB_DIR)\gcc_compat.h;$(NMakeForcedIncludes) 52 | "$(VISUALGDB_DIR)\VisualGDB.exe" /build "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 53 | "$(VISUALGDB_DIR)\VisualGDB.exe" /clean "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 54 | "$(VISUALGDB_DIR)\VisualGDB.exe" /rebuild "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)" 55 | $(ProjectDir)MyActor_mingw-Release.vgdbsettings 56 | 57 | 58 | 59 | __VisualGDB_CFG_Release;$(NMakePreprocessorDefinitions) 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /MyActor_mingw/MyActor_mingw.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {2924f8cc-41f7-443b-9b5e-255ec92637de} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {de7b2b90-e3fc-4755-b211-90118788f1ea} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {4ae17d84-fe72-4e05-9ac9-5919cfbaebfb} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | {151f90fe-b32b-4094-97ae-193508ec421a} 18 | *.mak 19 | 20 | 21 | 22 | 23 | 24 | Make files 25 | 26 | 27 | Make files 28 | 29 | 30 | 31 | 32 | Source files 33 | 34 | 35 | Source files 36 | 37 | 38 | -------------------------------------------------------------------------------- /MyActor_mingw/debug.mak: -------------------------------------------------------------------------------- 1 | #Generated by VisualGDB (http://visualgdb.com) 2 | #DO NOT EDIT THIS FILE MANUALLY UNLESS YOU ABSOLUTELY NEED TO 3 | #USE VISUALGDB PROJECT PROPERTIES DIALOG INSTEAD 4 | 5 | BINARYDIR := ..\x64\Debug 6 | 7 | #Toolchain 8 | CC := C:/mingw64/x86_64-4.9.3-release-posix-seh-rt_v4-rev1/mingw64/bin/gcc.exe 9 | CXX := C:/mingw64/x86_64-4.9.3-release-posix-seh-rt_v4-rev1/mingw64/bin/g++.exe 10 | LD := $(CXX) 11 | AR := C:/mingw64/x86_64-4.9.3-release-posix-seh-rt_v4-rev1/mingw64/bin/ar.exe 12 | OBJCOPY := 13 | 14 | #Additional flags 15 | PREPROCESSOR_MACROS := DEBUG _DEBUG WIN32 _WIN64 _WIN32_WINNT=0x0600 ENABLE_NEXT_TICK ENABLE_CHECK_LOST DISABLE_BOOST_TIMER 16 | INCLUDE_DIRS := D:\cpplib\boost 17 | LIBRARY_DIRS := D:\cpplib\boost\lib_mingw49\x64 18 | LIBRARY_NAMES := Mswsock Winmm ws2_32 boost_thread boost_system boost_chrono 19 | ADDITIONAL_LINKER_INPUTS := 20 | MACOS_FRAMEWORKS := 21 | LINUX_PACKAGES := 22 | 23 | CFLAGS := -ggdb -ffunction-sections -O0 24 | CXXFLAGS := -ggdb -ffunction-sections -Wa,-mbig-obj -O0 -std=c++11 -Wall -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable -Wno-delete-non-virtual-dtor -Wno-strict-aliasing 25 | ASFLAGS := 26 | LDFLAGS := -Wl,-gc-sections -static 27 | COMMONFLAGS := 28 | 29 | START_GROUP := -Wl,--start-group 30 | END_GROUP := -Wl,--end-group 31 | 32 | #Additional options detected from testing the toolchain 33 | -------------------------------------------------------------------------------- /MyActor_mingw/release.mak: -------------------------------------------------------------------------------- 1 | #Generated by VisualGDB (http://visualgdb.com) 2 | #DO NOT EDIT THIS FILE MANUALLY UNLESS YOU ABSOLUTELY NEED TO 3 | #USE VISUALGDB PROJECT PROPERTIES DIALOG INSTEAD 4 | 5 | BINARYDIR := ..\x64\Release 6 | 7 | #Toolchain 8 | CC := C:/mingw64/x86_64-4.9.3-release-posix-seh-rt_v4-rev1/mingw64/bin/gcc.exe 9 | CXX := C:/mingw64/x86_64-4.9.3-release-posix-seh-rt_v4-rev1/mingw64/bin/g++.exe 10 | LD := $(CXX) 11 | AR := C:/mingw64/x86_64-4.9.3-release-posix-seh-rt_v4-rev1/mingw64/bin/ar.exe 12 | OBJCOPY := 13 | 14 | #Additional flags 15 | PREPROCESSOR_MACROS := NDEBUG RELEASE WIN32 _WIN64 _WIN32_WINNT=0x0600 ENABLE_NEXT_TICK ENABLE_CHECK_LOST DISABLE_BOOST_TIMER 16 | INCLUDE_DIRS := D:\cpplib\boost 17 | LIBRARY_DIRS := D:\cpplib\boost\lib_mingw49\x64 18 | LIBRARY_NAMES := Mswsock Winmm ws2_32 boost_thread boost_system boost_chrono 19 | ADDITIONAL_LINKER_INPUTS := 20 | MACOS_FRAMEWORKS := 21 | LINUX_PACKAGES := 22 | 23 | CFLAGS := -ffunction-sections -O2 24 | CXXFLAGS := -ffunction-sections -O2 -fno-rtti -std=c++11 -Wall -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable -Wno-delete-non-virtual-dtor -Wno-strict-aliasing 25 | ASFLAGS := 26 | LDFLAGS := -Wl,-gc-sections -static 27 | COMMONFLAGS := 28 | 29 | START_GROUP := -Wl,--start-group 30 | END_GROUP := -Wl,--end-group 31 | 32 | #Additional options detected from testing the toolchain 33 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | C++版本已停止维护,请转到C#版本 2 | https://github.com/HAM-2015/CsGo 3 | https://gitee.com/hamasm/CsGo 4 | 5 | 并发逻辑控制框架,适用于复杂业务逻辑; 6 | 支持系统 windows、x86_x64/armv7_v8-linux、armv7_v8-android; 7 | 支持编译器 VC2013/VC2015,GCC4.8+; 8 | 依赖于boost 1.5x; 9 | 可以用来构建服务端/客户端,也可以用在与网络无关的程序中; 10 | 基于stackful/stackless协程技术,actor基于stackful,generator基于stackless; 11 | actor/generator均可以类似普通函数一样调用别的actor/generator函数及传递参数; 12 | actor运行时按需扩张栈空间(4K-1M),64位下4G内存最多可创建一千万以上generator对象; 13 | actor/generator之间多种0-copy消息通信方式; 14 | 1:n的方式划分串行调度队列,在不使用消息时也可有效规避多个actor/generator逻辑之间的线程安全问题; 15 | 三级调度,主流x86处理器单线程下actor调度一千万以上,generator两千万以上; 16 | 优化过的高效定时器,定时器资源非常轻量; 17 | 基于asio优化过的tcp/udp异步IO; 18 | 支持QT-UI线程调度驱动,极大简化UI与后台逻辑之间的交互; 19 | 私有项目,不提供开发文档,有兴趣请联系 591170887@qq.com; 20 | 可以任意使用或编辑源码,而不需通知作者,当然作者也不对使用本框架造成的任何损失负责. 21 | 22 | svn url(版本保持最新): 23 | svn://ham2015.6655.la:1000/MyActor 24 | Node.js版本(支持web前端js) 25 | svn://ham2015.6655.la:1000/MyActorNodeJs 26 | 27 | github url: 28 | https://github.com/HAM-2015/CPP-Actor-framework 29 | 30 | oschina url: 31 | http://git.oschina.net/hamasm/cpp-actor-framework 32 | 33 | ftp url: 34 | ftp://ham2015.6655.la/files/MyActor/ 35 | 36 | 2017-01-17 37 | 优化asio异步IO,在linux下tcp/udp更加高效; 38 | 39 | 2016-09-20 40 | 添加generator下的channel通信机制(无缓存/有限缓存/无限缓存),支持select-case方式读取多个channel; 41 | 添加generator下的逻辑mutex互斥. 42 | 43 | 2016-09-08 44 | 添加基于stackless的generator,支持co_yield、co_async、co_await、co_call语义. 45 | 46 | 2016-08-18 47 | 添加Node.Js与C++扩展模块之间Actor交互(测试Node.Js版本6.2.2). 48 | 49 | 2016-08-09 50 | 添加可以在Node.Js C++扩展动态库uv线程内运行Actor(测试Node.Js版本6.2.2). 51 | 52 | 2016-03-26 53 | 移植到arm-android(Linux-Kernel-3.4.0+)平台(包括 QT For Android 异步UI驱动). 54 | 55 | 2016-03-15 56 | 移植到arm-linux平台. 57 | 58 | 2015-12-28 59 | 添加linux平台下的自动栈空间伸缩管理. 60 | 61 | 2015-12-25 62 | 添加windows平台下的自动栈空间伸缩管理. 63 | 64 | 2015-12-18 65 | 添加对mingw的支持. 66 | 67 | 2015-12-09 68 | 优化windows,linux平台下的定时器性能. 69 | 70 | 2015-11-13 71 | 修改windows下使用Fiber驱动上下文切换. 72 | 73 | 2015-11-11 74 | 添加在QT-UI线程中运行Actor,驱动异步UI. 75 | 76 | 2015-11-05 77 | 添加"通知句柄"丢失检测,消息等待时可以捕获通知句柄丢失异常. 78 | 79 | 2015-10-31 80 | 移植到linux系统. 81 | 82 | 2015-09-24 83 | 改进采用TLS技术检测当前代码运行在哪个Actor下. 84 | 85 | 2015-09-21 86 | 使Actor在lock_quit()后检测到quit_msg消息仍然可以运行. 87 | 88 | 2015-08-23 89 | 让一个Actor内可以同时支持多个相同类型消息. 90 | 91 | 2015-08-02 92 | 添加在一个Actor内互斥运行多个业务逻辑段. 93 | 94 | 2015-07-30 95 | 支持任意参数个数消息. 96 | 97 | 2015-07-12 98 | 优化右值转移,使消息传递支持0拷贝. 99 | 添加值引用消息. 100 | 101 | 2015-07-10 102 | 二级调度器shared_strand添加next_tick功能,提高消息传递性能. 103 | 104 | 2015-06-26 105 | 优化Actor的内部定时器. 106 | 107 | 2015-06-12 108 | 添加同步消息(sync_msg)和CSP模型消息(csp_channel). 109 | 110 | 2015-06-09 111 | 去掉“actor_mutex”、“actor_shared_mutex”不必要的 close 功能. 112 | 113 | 2015-06-06 114 | 添加直接产生上下文的回调函数,可以不用显示使用await操作等待回调完成. 115 | 116 | 2015-06-03 117 | 优化检测堆栈溢出功能,输出具体哪个Actor溢出日志. 118 | 119 | 2015-06-01 120 | 优化等待子Actor结束的性能,取消等待返回bool值. 121 | 122 | 2015-05-29 123 | 添加actor_shared_mutex,用于业务逻辑之间的同步. 124 | 125 | 2015-05-24 126 | 添加在DEBUG下创建Actor时保存调用堆栈,方便某个Actor异常时调试跟踪. 127 | 128 | 2015-05-15 129 | 添加可以检测当前代码运行在哪个Actor下. 130 | 131 | 2015-04-14 132 | 核心功能整体优化; 133 | 添加actor_mutex; 134 | 添加可以暂时锁定Actor,不让其强制退出,用于关键逻辑段; 135 | 添加多级消息代理. 136 | 137 | 2015-04-02 138 | 添加可以直接拿一个Actor句柄发送消息,然后通过匹配弹出消息. 139 | 140 | 2015-03-19 141 | 添加消息传递的右值优化. 142 | 143 | 2015-02-11 144 | 添加定时清理Actor栈池. 145 | 146 | 2015-02-05 147 | 增加外部可以直接拿另一个Actor句柄创建一个消息管道或通知句柄. 148 | 149 | 2015-02-01 150 | 添加socket测试示例. 151 | 152 | 2015-01-26 153 | 修改了定时器在高版本VS下因与STL库冲突导致的编译错误问题; 154 | 增加异步触发和消息等待的超时处理功能. 155 | 156 | 2015-01-08 157 | 修改了挂起/恢复控制逻辑,原有逻辑在极端情况下存在安全风险. 158 | --------------------------------------------------------------------------------