Introduce extended set/get methods for ZMQ contexts (#3642)

* Introduce DRAFT zmq_ctx_set_ext() and zmq_ctx_get_ext() methods. Change
ZMQ_THREAD_NAME_PREFIX to allow for non-numeric thread name prefixes.
This commit is contained in:
Francesco Montorsi
2019-08-28 00:41:23 +02:00
committed by Luca Boccassi
parent 2aa87c94cc
commit b3582da8fb
8 changed files with 465 additions and 97 deletions

View File

@@ -116,7 +116,6 @@ void test_ctx_thread_opts ()
}
#ifdef ZMQ_THREAD_AFFINITY_CPU_ADD
// test affinity:
// this should result in background threads being placed only on the
@@ -138,16 +137,28 @@ void test_ctx_thread_opts ()
ZMQ_THREAD_AFFINITY_CPU_REMOVE,
cpus_remove[idx]));
}
#endif
#ifdef ZMQ_THREAD_NAME_PREFIX
// test thread name prefix:
// test INTEGER thread name prefix:
TEST_ASSERT_SUCCESS_ERRNO (
zmq_ctx_set (get_test_context (), ZMQ_THREAD_NAME_PREFIX, 1234));
TEST_ASSERT_EQUAL_INT (
1234, zmq_ctx_get (get_test_context (), ZMQ_THREAD_NAME_PREFIX));
#ifdef ZMQ_BUILD_DRAFT_API
// test STRING thread name prefix:
const char prefix[] = "MyPrefix9012345"; // max len is 16 chars
TEST_ASSERT_SUCCESS_ERRNO (
zmq_ctx_set_ext (get_test_context (), ZMQ_THREAD_NAME_PREFIX, prefix,
sizeof (prefix) / sizeof (char)));
char buf[16];
size_t buflen = sizeof (buf) / sizeof (char);
zmq_ctx_get_ext (get_test_context (), ZMQ_THREAD_NAME_PREFIX, buf, &buflen);
TEST_ASSERT_EQUAL_STRING (prefix, buf);
#endif
}