@@ -824,7 +824,7 @@ class Tracepoints {
824
824
825
825
xpti::TracePointImpl *TP = reinterpret_cast <xpti::TracePointImpl *>(UId);
826
826
if (xpti::is_valid_event (&TP->MEvent ))
827
- return reinterpret_cast <xpti_trace_event_t *>(TP);
827
+ return dynamic_cast <xpti_trace_event_t *>(TP);
828
828
else
829
829
return nullptr ;
830
830
}
@@ -880,7 +880,7 @@ class Tracepoints {
880
880
881
881
xpti::uid128_t UId = TP->MUId ;
882
882
{
883
- std::unique_lock Lock (MTracepointMutex);
883
+ std::unique_lock<std::shared_mutex> Lock (MTracepointMutex);
884
884
// Find the event list for a given UID
885
885
auto &Instances = MTracepoints[UId];
886
886
MUID64Check.erase (UId.uid64 );
@@ -1017,7 +1017,7 @@ class Tracepoints {
1017
1017
// Check is Key is valid; If the payload is fully populated, then we will
1018
1018
// have both Key.p1 and Key.p2 set. However, if only a function name is
1019
1019
// provided, then we will have Key.p1 populated.
1020
- std::unique_lock Lock (MPayloadMutex);
1020
+ std::unique_lock<std::shared_mutex> Lock (MPayloadMutex);
1021
1021
auto &PayloadEntry = MPayloads[Key];
1022
1022
if (PayloadEntry.first .flags == 0 ) {
1023
1023
#ifdef XPTI_STATISTICS
@@ -1066,7 +1066,7 @@ class Tracepoints {
1066
1066
return nullptr ;
1067
1067
1068
1068
// Lock the mutex to ensure thread-safe access to the tracepoints map
1069
- std::unique_lock Lock (MTracepointMutex);
1069
+ std::unique_lock<std::shared_mutex> Lock (MTracepointMutex);
1070
1070
// Access or create the tracepoint instance associated with the universal ID
1071
1071
auto &Tracepoint = MTracepoints[UniversalId];
1072
1072
// Access or create the specific instance of the tracepoint based on the
@@ -1101,7 +1101,7 @@ class Tracepoints {
1101
1101
{
1102
1102
xpti::uid128_t UId = TP->MUId ;
1103
1103
// Lock the mutex to ensure thread-safe access to the tracepoints map
1104
- std::unique_lock Lock (MTracepointMutex);
1104
+ std::unique_lock<std::shared_mutex> Lock (MTracepointMutex);
1105
1105
// Find the tracepoint for a given UID
1106
1106
auto &Instances = MTracepoints[UId];
1107
1107
// Now release the 64-bit UID associated with tracepoint instance
@@ -1458,7 +1458,7 @@ class Notifications {
1458
1458
#endif
1459
1459
// If reader-writer locks were emplyed, this is where the writer lock can
1460
1460
// be used
1461
- std::unique_lock Lock (MCBsLock);
1461
+ std::unique_lock<std::shared_mutex> Lock (MCBsLock);
1462
1462
auto &TraceFlags = MStreamFlags[StreamID]; // Get the trace flags for the
1463
1463
// stream ID
1464
1464
TraceFlags[TraceType] = true ; // Set the trace type flag to true
@@ -1533,7 +1533,7 @@ class Notifications {
1533
1533
// Since we do not remove the callback function when they are unregistered
1534
1534
// and only reset the flag, the writer lock is not held for very long; use
1535
1535
// writer lock here.
1536
- std::unique_lock Lock (MCBsLock);
1536
+ std::unique_lock<std::shared_mutex> Lock (MCBsLock);
1537
1537
auto &TraceFlags = MStreamFlags[StreamID]; // Get the trace flags for the
1538
1538
// stream ID
1539
1539
TraceFlags[TraceType] = false ; // Set the trace type flag to false
@@ -1587,7 +1587,7 @@ class Notifications {
1587
1587
// If there are no callbacks registered for the requested stream ID, we
1588
1588
// return not found; use reader lock here if the implementation moves to
1589
1589
// reader-writer locks.
1590
- std::unique_lock Lock (MCBsLock);
1590
+ std::unique_lock<std::shared_mutex> Lock (MCBsLock);
1591
1591
if (MCallbacksByStream.count (StreamID) == 0 )
1592
1592
return xpti::result_t ::XPTI_RESULT_NOTFOUND;
1593
1593
@@ -1699,7 +1699,7 @@ class Notifications {
1699
1699
// the notification functions when the lock is held and then releases
1700
1700
// the lock before calling the notification functions. When using
1701
1701
// reader-writer locks, use reader lock here.
1702
- std::shared_lock Lock (MCBsLock);
1702
+ std::shared_lock<std::shared_mutex> Lock (MCBsLock);
1703
1703
cb_t &Stream = MCallbacksByStream[StreamID]; // Thread-safe
1704
1704
Acc = Stream.find (TraceType);
1705
1705
Success = (Acc != Stream.end ());
0 commit comments