Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
22c3ecc4
Commit
22c3ecc4
authored
Nov 18, 2018
by
Luca Boccassi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: some context options have no getter
Solution: add one so that class-based bindings can easily use them
parent
92cf6c64
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
2 deletions
+45
-2
zmq_ctx_get.txt
doc/zmq_ctx_get.txt
+18
-0
ctx.cpp
src/ctx.cpp
+20
-2
ctx.hpp
src/ctx.hpp
+1
-0
test_ctx_options.cpp
tests/test_ctx_options.cpp
+6
-0
No files found.
doc/zmq_ctx_get.txt
View file @
22c3ecc4
...
...
@@ -64,6 +64,24 @@ zero if the "block forever on context termination" gambit was disabled by
setting ZMQ_BLOCKY to false on all new contexts.
ZMQ_THREAD_SCHED_POLICY: Get scheduling policy for I/O threads
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_THREAD_SCHED_POLICY' argument returns the scheduling policy for
internal context's thread pool.
ZMQ_THREAD_PRIORITY: Get scheduling priority for I/O threads
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_THREAD_PRIORITY' argument returns the scheduling priority for
internal context's thread pool.
ZMQ_THREAD_NAME_PREFIX: Get name prefix for I/O threads
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_THREAD_NAME_PREFIX' argument gets the numeric prefix of each thread
created for the internal context's thread pool.
ZMQ_MSG_T_SIZE: Get the zmq_msg_t size at runtime
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_MSG_T_SIZE' argument returns the size of the zmq_msg_t structure at
...
...
src/ctx.cpp
View file @
22c3ecc4
...
...
@@ -271,8 +271,7 @@ int zmq::ctx_t::get (int option_)
else
if
(
option_
==
ZMQ_ZERO_COPY_RECV
)
{
rc
=
_zero_copy
;
}
else
{
errno
=
EINVAL
;
rc
=
-
1
;
rc
=
thread_ctx_t
::
get
(
option_
);
}
return
rc
;
}
...
...
@@ -467,6 +466,25 @@ int zmq::thread_ctx_t::set (int option_, int optval_)
return
rc
;
}
int
zmq
::
thread_ctx_t
::
get
(
int
option_
)
{
int
rc
=
0
;
if
(
option_
==
ZMQ_THREAD_PRIORITY
)
{
scoped_lock_t
locker
(
_opt_sync
);
rc
=
_thread_priority
;
}
else
if
(
option_
==
ZMQ_THREAD_SCHED_POLICY
)
{
scoped_lock_t
locker
(
_opt_sync
);
rc
=
_thread_sched_policy
;
}
else
if
(
option_
==
ZMQ_THREAD_NAME_PREFIX
)
{
scoped_lock_t
locker
(
_opt_sync
);
rc
=
atoi
(
_thread_name_prefix
.
c_str
());
}
else
{
errno
=
EINVAL
;
rc
=
-
1
;
}
return
rc
;
}
void
zmq
::
ctx_t
::
send_command
(
uint32_t
tid_
,
const
command_t
&
command_
)
{
_slots
[
tid_
]
->
send
(
command_
);
...
...
src/ctx.hpp
View file @
22c3ecc4
...
...
@@ -70,6 +70,7 @@ class thread_ctx_t
void
start_thread
(
thread_t
&
thread_
,
thread_fn
*
tfn_
,
void
*
arg_
)
const
;
int
set
(
int
option_
,
int
optval_
);
int
get
(
int
option_
);
protected
:
// Synchronisation of access to context options.
...
...
tests/test_ctx_options.cpp
View file @
22c3ecc4
...
...
@@ -92,6 +92,8 @@ void test_ctx_thread_opts (void *ctx_)
// as of ZMQ 4.2.3 this has an effect only on POSIX systems (nothing happens on Windows, but still it should return success):
rc
=
zmq_ctx_set
(
ctx_
,
ZMQ_THREAD_SCHED_POLICY
,
TEST_POLICY
);
assert
(
rc
==
0
);
rc
=
zmq_ctx_get
(
ctx_
,
ZMQ_THREAD_SCHED_POLICY
);
assert
(
rc
==
TEST_POLICY
);
// test priority:
...
...
@@ -110,6 +112,8 @@ void test_ctx_thread_opts (void *ctx_)
ctx_
,
ZMQ_THREAD_PRIORITY
,
1
/* any positive value different than the default will be ok */
);
assert
(
rc
==
0
);
rc
=
zmq_ctx_get
(
ctx_
,
ZMQ_THREAD_PRIORITY
);
assert
(
rc
==
1
);
}
...
...
@@ -143,6 +147,8 @@ void test_ctx_thread_opts (void *ctx_)
rc
=
zmq_ctx_set
(
ctx_
,
ZMQ_THREAD_NAME_PREFIX
,
1234
);
assert
(
rc
==
0
);
rc
=
zmq_ctx_get
(
ctx_
,
ZMQ_THREAD_NAME_PREFIX
);
assert
(
rc
==
1234
);
#endif
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment