Skip to content

Commit 91b5f8a

Browse files
committed
[Example] Multi-threaded programming example
1 parent 3bdbebc commit 91b5f8a

File tree

19 files changed

+334
-8
lines changed

19 files changed

+334
-8
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ list all pods in cluster:
125125
apiClient_unsetupGlobalEnv();
126126
```
127127

128+
## Multi-threaded Usage
129+
130+
If the C client library is used in multi-threaded program, the following 2 actions must be taken:
131+
132+
1. After the program starts up, main thread must call the function ```apiClient_setupGlobalEnv()``` before any worker thread is created.
133+
134+
2. If the C client is no longer used, main thread must call the function ```apiClient_unsetupGlobalEnv()``` after all worker threads end.
135+
136+
Refer to the [example](https://github.com/kubernetes-client/c/tree/master/examples/multi_thread/) for detail.
128137

129138
## Community, discussion, contribution, and support
130139

examples/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ all:
77
cd generic; make
88
cd auth_provider; make
99
cd watch_list_pod; make
10+
cd multi_thread; make
1011

1112
clean:
1213
cd create_pod; make clean
@@ -17,3 +18,4 @@ clean:
1718
cd generic; make clean
1819
cd auth_provider; make clean
1920
cd watch_list_pod; make clean
21+
cd multi_thread; make clean

examples/auth_provider/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
INCLUDE:=-I../../kubernetes/include -I../../kubernetes/model -I../../kubernetes/api -I../../kubernetes/config
2-
LIBS:=-L../../kubernetes/build -lkubernetes -lcurl -lyaml -lpthread -lssl -lz
2+
LIBS:=-L../../kubernetes/build -lkubernetes -lyaml
33
CFLAGS:=-g
44

55
all:

examples/create_pod/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
INCLUDE:=-I../../kubernetes/include -I../../kubernetes/model -I../../kubernetes/api -I../../kubernetes/config
2-
LIBS:=-L../../kubernetes/build -lkubernetes -lcurl -lyaml -lpthread -lssl -lz
2+
LIBS:=-L../../kubernetes/build -lkubernetes -lyaml
33
CFLAGS:=-g
44

55
all:

examples/delete_pod/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
INCLUDE:=-I../../kubernetes/include -I../../kubernetes/model -I../../kubernetes/api -I../../kubernetes/config
2-
LIBS:=-L../../kubernetes/build -lkubernetes -lcurl -lyaml -lpthread -lssl -lz
2+
LIBS:=-L../../kubernetes/build -lkubernetes -lyaml
33
CFLAGS:=-g
44
BIN:=delete_pod_bin
55

examples/exec_provider/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
INCLUDE:=-I../../kubernetes/include -I../../kubernetes/model -I../../kubernetes/api -I../../kubernetes/config
2-
LIBS:=-L../../kubernetes/build -lkubernetes -lcurl -lyaml -lpthread -lssl -lz
2+
LIBS:=-L../../kubernetes/build -lkubernetes -lyaml
33
CFLAGS:=-g
44

55
all: my_exec_provider_bin list_pod_by_exec_provider_bin

examples/generic/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
INCLUDE:=-I../../kubernetes/include -I../../kubernetes/model -I../../kubernetes/api -I../../kubernetes/config
2-
LIBS:=-L../../kubernetes/build -lkubernetes -lcurl -lyaml -lpthread -lssl -lz
2+
LIBS:=-L../../kubernetes/build -lkubernetes -lyaml
33
CFLAGS:=-g
44

55
all:

examples/list_pod/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
INCLUDE:=-I../../kubernetes/include -I../../kubernetes/model -I../../kubernetes/api -I../../kubernetes/config
2-
LIBS:=-L../../kubernetes/build -lkubernetes -lcurl -lyaml -lpthread -lssl -lz
2+
LIBS:=-L../../kubernetes/build -lkubernetes -lyaml
33
CFLAGS:=-g
44

55
all:

examples/list_pod_incluster/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
INCLUDE:=-I../../kubernetes/include -I../../kubernetes/model -I../../kubernetes/api -I../../kubernetes/config
2-
LIBS:=-L../../kubernetes/build -lkubernetes -lcurl -lyaml -lpthread -lssl -lz
2+
LIBS:=-L../../kubernetes/build -lkubernetes -lyaml
33
CFLAGS:=-g
44

55
all:

examples/multi_thread/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
multi_thread_bin

0 commit comments

Comments
 (0)