wwbmmm commented on code in PR #3158:
URL: https://github.com/apache/brpc/pull/3158#discussion_r2545872066
##########
src/bthread/types.h:
##########
@@ -97,12 +97,14 @@ typedef struct {
size_t nfree;
} bthread_keytable_pool_stat_t;
+static const size_t BTHREAD_NAME_MAX_LENGTH = 31;
// Attributes for thread creation.
typedef struct bthread_attr_t {
bthread_stacktype_t stack_type;
bthread_attrflags_t flags;
bthread_keytable_pool_t* keytable_pool;
bthread_tag_t tag;
+ char name[BTHREAD_NAME_MAX_LENGTH + 1]; // do not use std::string to keep
POD
Review Comment:
Some existing user code may create bthread_attr_t without initialize the
`name`.
For backward compatibility, I think you can add a flag to the
`bthread_attrflags_t flags` like `BTHREAD_HAS_NAME`. Only when this flag is
on, the name will be used.
##########
src/bthread/types.h:
##########
@@ -118,6 +120,12 @@ typedef struct bthread_attr_t {
return tmp;
}
#endif // __cplusplus
+ void set_name(const char* val) {
Review Comment:
This is C++ style interface
but the original bthread interface is designed as C style.
maybe you can add a global function `bthread_attr_set_name`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]