xaizek / pms (License: GPLv3+) (since 2018-12-07)
Older version of Practical Music Search written in C++.
Commit ec83c51d531811dc8ec3a1afc18653f3ba2ebc7d

Move functions out of assert() statements
Author: Kim Tore Jensen
Author date (UTC): 2015-08-25 16:38
Committer name: Kim Tore Jensen
Committer date (UTC): 2015-08-25 16:38
Parent(s): df45b558a8ec33b496ab43510627c19c0deda166
Signing key:
Tree: 705d45b12bf8a219175583a6bf9dba33bf809839
File Lines added Lines deleted
src/pms.cpp 4 2
src/zeromq.cpp 17 6
File src/pms.cpp changed (mode: 100644) (index dcaec63..a0d9070)
... ... idle_thread_main(void * zeromq_context)
92 92 socket = zmq_socket(zeromq_context, ZMQ_REP); socket = zmq_socket(zeromq_context, ZMQ_REP);
93 93 assert(socket != NULL); assert(socket != NULL);
94 94
95 assert(zmq_bind(socket, ZEROMQ_SOCKET_IDLE) == 0);
95 rc = zmq_bind(socket, ZEROMQ_SOCKET_IDLE);
96 assert(rc == 0);
96 97
97 98 do { do {
98 99 /* Receive from main thread */ /* Receive from main thread */
 
... ... input_thread_main(void * zeromq_context)
140 141 socket = zmq_socket(zeromq_context, ZMQ_PUB); socket = zmq_socket(zeromq_context, ZMQ_PUB);
141 142 assert(socket != NULL); assert(socket != NULL);
142 143
143 assert(zmq_connect(socket, ZEROMQ_SOCKET_INPUT) == 0);
144 rc = zmq_connect(socket, ZEROMQ_SOCKET_INPUT);
145 assert(rc == 0);
144 146
145 147 do { do {
146 148 /* Poll for user input */ /* Poll for user input */
File src/zeromq.cpp changed (mode: 100644) (index 061dc4e..9eaace3)
... ... ZeroMQ::get_idle_events()
68 68 void void
69 69 ZeroMQ::continue_idle() ZeroMQ::continue_idle()
70 70 { {
71 assert(zmq_send(socket_idle, NULL, 0, 0) == 0);
71 int rc;
72 rc = zmq_send(socket_idle, NULL, 0, 0);
73 assert(rc == 0);
72 74 } }
73 75
74 76 /* Check for events on the input socket. */ /* Check for events on the input socket. */
 
... ... ZeroMQ::get_input_events()
97 99 void void
98 100 ZeroMQ::start_thread_idle(void *(*func) (void *)) ZeroMQ::start_thread_idle(void *(*func) (void *))
99 101 { {
100 assert(pthread_create(&idle_thread, NULL, func, context) == 0);
102 int rc;
103 rc = pthread_create(&idle_thread, NULL, func, context);
104 assert(rc == 0);
101 105 } }
102 106
103 107 /** /**
 
... ... ZeroMQ::start_thread_idle(void *(*func) (void *))
106 110 void void
107 111 ZeroMQ::start_thread_input(void *(*func) (void *)) ZeroMQ::start_thread_input(void *(*func) (void *))
108 112 { {
109 assert(pthread_create(&input_thread, NULL, func, context) == 0);
113 int rc;
114 rc = pthread_create(&input_thread, NULL, func, context);
115 assert(rc == 0);
110 116 } }
111 117
112 118 /** /**
 
... ... ZeroMQ::start_thread_input(void *(*func) (void *))
114 120 */ */
115 121 ZeroMQ::ZeroMQ() ZeroMQ::ZeroMQ()
116 122 { {
123 int rc;
124
117 125 /* Initialize ZeroMQ context and sockets */ /* Initialize ZeroMQ context and sockets */
118 126 context = zmq_ctx_new(); context = zmq_ctx_new();
119 127 assert(context != NULL); assert(context != NULL);
 
... ... ZeroMQ::ZeroMQ()
121 129 assert(socket_idle != NULL); assert(socket_idle != NULL);
122 130 socket_input = zmq_socket(context, ZMQ_SUB); socket_input = zmq_socket(context, ZMQ_SUB);
123 131 assert(socket_input != NULL); assert(socket_input != NULL);
124 assert(zmq_setsockopt(socket_input, ZMQ_SUBSCRIBE, "", 0) == 0);
125 assert(zmq_connect(socket_idle, ZEROMQ_SOCKET_IDLE) == 0);
126 assert(zmq_bind(socket_input, ZEROMQ_SOCKET_INPUT) == 0);
132 rc = zmq_setsockopt(socket_input, ZMQ_SUBSCRIBE, "", 0);
133 assert(rc == 0);
134 rc = zmq_connect(socket_idle, ZEROMQ_SOCKET_IDLE);
135 assert(rc == 0);
136 rc = zmq_bind(socket_input, ZEROMQ_SOCKET_INPUT);
137 assert(rc == 0);
127 138
128 139 /* Set up ZeroMQ poller */ /* Set up ZeroMQ poller */
129 140 poll_items[0].socket = socket_idle; poll_items[0].socket = socket_idle;
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/pms

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/pms

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master