forked from XRPLF/rippled
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce replacement for getting and setting thread name: (XRPLF#4312)
* In namespace ripple, introduces get_name function that takes a std::thread::native_handle_type and returns a std::string. * In namespace ripple, introduces get_name function that takes a std::thread or std::jthread and returns a std::string. * In namespace ripple::this_thread, introduces get_name function that takes no parameters and returns the name of the current thread as a std::string. * In namespace ripple::this_thread, introduces set_name function that takes a std::string_view and sets the name of the current thread. * Intended to replace the beast utilities setCurrentThreadName and getCurrentThreadName.
- Loading branch information
1 parent
3bd96b9
commit 6bc7962
Showing
21 changed files
with
205 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of Beast: https://github.com/vinniefalco/Beast | ||
Copyright 2013, Vinnie Falco <[email protected]> | ||
Portions of this file are from JUCE. | ||
Copyright (c) 2013 - Raw Material Software Ltd. | ||
Please visit http://www.juce.com | ||
This file is part of rippled: https://github.com/ripple/rippled | ||
Copyright (c) 2022 Ripple Labs Inc. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -21,31 +17,34 @@ | |
*/ | ||
//============================================================================== | ||
|
||
#ifndef BEAST_CORE_CURRENT_THREAD_NAME_H_INCLUDED | ||
#define BEAST_CORE_CURRENT_THREAD_NAME_H_INCLUDED | ||
#ifndef RIPPLE_BASICS_THREADUTILITIES_H_INCLUDED | ||
#define RIPPLE_BASICS_THREADUTILITIES_H_INCLUDED | ||
|
||
#include <string> | ||
#include <string_view> | ||
#include <thread> | ||
|
||
namespace beast { | ||
namespace ripple { | ||
|
||
/** Changes the name of the caller thread. | ||
Different OSes may place different length or content limits on this name. | ||
*/ | ||
void | ||
setCurrentThreadName(std::string_view newThreadName); | ||
std::string | ||
get_name(std::thread::native_handle_type t); | ||
|
||
/** Returns the name of the caller thread. | ||
template <class Thread> | ||
inline auto | ||
get_name(Thread& t) -> decltype(t.native_handle(), t.join(), std::string{}) | ||
{ | ||
return get_name(t.native_handle()); | ||
} | ||
|
||
The name returned is the name as set by a call to setCurrentThreadName(). | ||
If the thread name is set by an external force, then that name change | ||
will not be reported. | ||
namespace this_thread { | ||
|
||
If no name has ever been set, then the empty string is returned. | ||
*/ | ||
std::string | ||
getCurrentThreadName(); | ||
get_name(); | ||
|
||
void | ||
set_name(std::string s); | ||
|
||
} // namespace this_thread | ||
|
||
} // namespace beast | ||
} // namespace ripple | ||
|
||
#endif |
Oops, something went wrong.