Skip to content

Commit 34ceafe

Browse files
添加分区说明
1 parent 7346386 commit 34ceafe

27 files changed

+148
-28
lines changed

MQ/kafka.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ image::mq/image-2024-09-24-15-34-08-363.png[]
7878
.主备机分区
7979
image::mq/image-2024-09-24-21-14-51-364.png[]
8080

81+
有了副本之后,如果原先的分区挂了,那么会在副本Follower所在的分区选举出一个新的主分区Leader partition,这样就实现了消息的灾备,保证了消息队列的高可用性。
8182

8283

8384

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/CMakeLists.txt

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,41 @@ target_include_directories(main
1212
target_link_libraries(main
1313
PUBLIC pthread)
1414

15-
add_executable(memory_management
16-
memory_management/memory_management.cpp)
17-
target_include_directories(memory_management
18-
PUBLIC memory_management
19-
PUBLIC ../inc)
15+
#add_executable(memory/memory_management
16+
# memory/memory_management/memory_management.cpp)
17+
#target_include_directories(memory/memory_management
18+
# PUBLIC memory/memory_management
19+
# PUBLIC ../inc)
2020

21-
add_executable(exception_sample
22-
exception_sample/exception_sample.cpp)
23-
target_include_directories(exception_sample
24-
PUBLIC exception_sample
25-
PUBLIC ../inc)
21+
#add_executable(C++/exception_sample
22+
# C++/exception_sample/exception_sample.cpp)
23+
#target_include_directories(C++/exception_sample
24+
# PUBLIC C++/exception_sample
25+
# PUBLIC ../inc)
2626

2727

2828
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
2929
MESSAGE(STATUS "current platform: Linux ")
3030

31-
add_executable(ftrace
32-
ftrace/ftrace.c)
31+
add_executable(linux/ftrace
32+
linux/ftrace/ftrace.c)
3333

34-
add_executable(tracer
35-
tracer/tracer.c)
34+
add_executable(linux/tracer
35+
linux/tracer/tracer.c)
3636

3737
add_executable(tracer2
38-
tracer/tracer2.c)
38+
linux/tracer/tracer2.c)
3939

4040
add_executable(tracer_test
41-
tracer/tracer_test.c)
41+
linux/tracer/tracer_test.c)
4242

43-
add_executable(elf_parser
44-
elf_parser/elf_parser.cpp)
43+
add_executable(C++/elf_parser
44+
C++/elf_parser/elf_parser.cpp)
4545

4646
add_executable(elf_main
47-
elf_parser/main.c)
47+
C++/elf_parser/main.c)
4848

49+
add_subdirectory(linux)
4950

5051
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
5152
MESSAGE(STATUS "current platform: Windows")
@@ -62,24 +63,26 @@ ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
6263
#add_executable(db_example
6364
# db/db_example.cpp)
6465

65-
add_executable(semaphore
66-
semaphore/semaphore.cpp)
67-
68-
add_executable(stack_frame
69-
stack_frames/stack_frames.cpp)
70-
66+
#add_executable(linux/semaphore
67+
# linux/semaphore/semaphore.cpp)
68+
#
69+
#add_executable(stack_frame
70+
# C++/stack_frames/stack_frames.cpp)
7171

7272

73-
add_executable(lru lru_cache/lru_cache.cpp)
7473

75-
add_subdirectory(smart_ptr)
74+
#add_executable(lru algorithm/lru_cache/lru_cache.cpp)
75+
#
76+
add_subdirectory(C++/smart_ptr)
7677

77-
add_subdirectory(track_new)
78+
add_subdirectory(linux/track_new)
7879

7980
add_subdirectory(allocator)
8081

8182
add_subdirectory(utils)
8283

84+
add_subdirectory(memory)
85+
8386
#add_subdirectory(tie)
8487

8588

File renamed without changes.

src/linux/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# all cpp files
2+
file(GLOB_RECURSE CPP_SRC_LIST ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
3+
4+
#message(STATUS ${CMAKE_CURRENT_LIST_DIR})
5+
6+
# generate target for every cpp file
7+
foreach(v ${CPP_SRC_LIST})
8+
# file relative path from src/
9+
string(REGEX MATCH ".*" relative_path ${v})
10+
# message(STATUS ${relative_path})
11+
12+
# delete string "src/"
13+
string(REGEX REPLACE "${CMAKE_CURRENT_LIST_DIR}/" "" target_name ${relative_path})
14+
# message(STATUS ${target_name})
15+
# rename '/' and '.' to '_'
16+
string(REGEX REPLACE "/|\\." "_" target_name ${target_name})
17+
18+
add_executable(${target_name} ${v})
19+
target_link_libraries(${target_name}
20+
pthread)
21+
endforeach()
22+
23+
24+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/main.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ int main(int argc, char* argv[]) {
2828

2929

3030

31+
std::map<int, int> IntMap;
32+
33+
IntMap.insert(std::make_pair(1,3));
34+
35+
auto iter = IntMap.find(2);
36+
if (iter == IntMap.end()) {
37+
IntMap.erase(iter);
38+
}
39+
40+
41+
3142

3243

3344

src/memory/CMakeLists.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
3+
# Set up the project
4+
5+
#
6+
## all cpp files
7+
#file(GLOB_RECURSE CPP_SRC_LIST ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
8+
## generate target for every cpp file
9+
#foreach(v ${CPP_SRC_LIST})
10+
# # file relative path from src/
11+
# string(REGEX MATCH ".*" relative_path ${v})
12+
## # delete string "src/"
13+
# string(REGEX REPLACE "src/" "" target_name ${relative_path})
14+
# # rename '/' and '.' to '_'
15+
# string(REGEX REPLACE "/|\\." "_" target_name ${target_name})
16+
#
17+
# add_executable(${target_name}_demo ${v})
18+
# target_link_libraries(${target_name}_demo
19+
# gtest
20+
# gmock
21+
# gtest_main
22+
# pthread)
23+
#endforeach()
24+
25+
26+
# all cpp files
27+
file(GLOB_RECURSE CPP_SRC_LIST ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
28+
29+
#message(STATUS ${CMAKE_CURRENT_LIST_DIR})
30+
31+
# generate target for every cpp file
32+
foreach(v ${CPP_SRC_LIST})
33+
# file relative path from src/
34+
string(REGEX MATCH ".*" relative_path ${v})
35+
# message(STATUS ${relative_path})
36+
37+
# delete string "src/"
38+
string(REGEX REPLACE "${CMAKE_CURRENT_LIST_DIR}/" "" target_name ${relative_path})
39+
# message(STATUS ${target_name})
40+
# rename '/' and '.' to '_'
41+
string(REGEX REPLACE "/|\\." "_" target_name ${target_name})
42+
43+
add_executable(${target_name} ${v})
44+
target_link_libraries(${target_name}
45+
pthread)
46+
endforeach()
47+
48+
49+

src/memory/virtual_memory_layout.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// Created by wangyz38535 on 2024/9/25.
3+
//
4+
5+
// virtual memory layout display
6+
7+
#include <stdio.h>
8+
#include <stdlib.h>
9+
#define PRINT_DELIMITER() printf("------------------------\n");
10+
#define PRINT_MEM_SEG(seg, addr) printf("[%s]: %p\n", seg, addr);
11+
static void func(void)
12+
{
13+
printf("hello\n");
14+
}
15+
16+
int main(int argc, char *argv[])
17+
{
18+
PRINT_DELIMITER();
19+
PRINT_MEM_SEG("CMD LINE ARGS", &argv[0]);
20+
int stack_var = 25;
21+
PRINT_DELIMITER();
22+
PRINT_MEM_SEG("STACK", &stack_var);
23+
int *heap_ptr = static_cast<int *>(malloc(sizeof(int)));
24+
PRINT_DELIMITER();
25+
PRINT_MEM_SEG("HEAP", heap_ptr);
26+
static int data_var = 10;
27+
PRINT_DELIMITER();
28+
PRINT_MEM_SEG("DATA", &data_var);
29+
PRINT_DELIMITER();
30+
PRINT_MEM_SEG("TEXT", func);
31+
return 0;
32+
}
File renamed without changes.

0 commit comments

Comments
 (0)