Skip to content

Commit

Permalink
use BOF_MUTEX everywhere with PriorityInversionAware_B param
Browse files Browse the repository at this point in the history
  • Loading branch information
bha-evs committed Feb 27, 2024
1 parent 34a104d commit 29b8b3c
Show file tree
Hide file tree
Showing 55 changed files with 639 additions and 464 deletions.
31 changes: 16 additions & 15 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ set(CONIO_SHELL_FILES
set(CONTAINER_FILES
# include/bofstd/bofspscqueue.h
# include/bofstd/bofmpmcqueue.h
include/bofstd/bofbuffer.h
src/bofbuffer.cpp
include/bofstd/bofcircularbuffer.h
include/bofstd/bofstringcircularbuffer.h
src/bofstringcircularbuffer.cpp
Expand Down Expand Up @@ -173,10 +175,10 @@ set(LOG_FILES
src/boflogger.cpp
)

set(OBSERVER_FILES
include/bofstd/bofobserver.h
src/bofobserver.cpp
)
#set(OBSERVER_FILES
# include/bofstd/bofobserver.h
# src/bofobserver.cpp
#)

set(PROTOCOL_FILES
include/bofstd/bofrpc.h
Expand All @@ -201,18 +203,17 @@ set(SERDER_FILES
set(SOCKIO_FILES
include/bofstd/bofsocketthread.h
src/bofsocketthread.cpp
include/bofstd/bofsocketserver.h
src/bofsocketserver.cpp
include/bofstd/bofsocketio.h
src/bofsocketio.cpp
include/bofstd/bofsocketsessionmanager.h
src/bofsocketsessionmanager.cpp
include/bofstd/ibofsocketio.h
include/bofstd/ibofsocketsessionfactory.h
# include/bofstd/bofsocketserver.h
# src/bofsocketserver.cpp
# include/bofstd/bofsocketio.h
# src/bofsocketio.cpp
# include/bofstd/bofsocketsessionmanager.h
# src/bofsocketsessionmanager.cpp
# include/bofstd/ibofsocketio.h
# include/bofstd/ibofsocketsessionfactory.h
)

set(SYSTEM_FILES
include/bofstd/bofbuffer.h
include/bofstd/bofsystem.h
src/bofsystem.cpp
include/bofstd/bofscopeguard.h
Expand Down Expand Up @@ -260,7 +261,7 @@ set(SOURCES_FILES
${FS_FILES}
${IXML_FILES}
${LOG_FILES}
${OBSERVER_FILES}
# ${OBSERVER_FILES}
${PROTOCOL_FILES}
${SERDER_FILES}
${SOCKIO_FILES}
Expand All @@ -287,7 +288,7 @@ source_group("EnumFlag" FILES ${ENUM_FLAG_FILES})
source_group("Fs" FILES ${FS_FILES})
source_group("Xml" FILES ${IXML_FILES})
source_group("Log" FILES ${LOG_FILES})
source_group("Observer" FILES ${OBSERVER_FILES})
#source_group("Observer" FILES ${OBSERVER_FILES})
source_group("Protocol" FILES ${PROTOCOL_FILES})
source_group("SerDeser" FILES ${SERDER_FILES})
source_group("SockIo" FILES ${SOCKIO_FILES})
Expand Down
20 changes: 13 additions & 7 deletions lib/include/bofstd/bofasync.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ BEGIN_BOF_NAMESPACE()
struct BOF_COMMAND_QUEUE_PARAM
{
uint64_t ThreadCpuCoreAffinityMask_U64;
bool MultiThreadAware_B;
bool PriorityInversionAware_B;
BOF_THREAD_SCHEDULER_POLICY ThreadSchedulerPolicy_E;
BOF_THREAD_PRIORITY ThreadPriority_E;
uint32_t MaxPendingRequest_U32;
Expand All @@ -41,6 +43,8 @@ struct BOF_COMMAND_QUEUE_PARAM
void Reset()
{
ThreadCpuCoreAffinityMask_U64 = 0;
MultiThreadAware_B=false;
PriorityInversionAware_B=false;
ThreadSchedulerPolicy_E = BOF_THREAD_SCHEDULER_POLICY_OTHER;
ThreadPriority_E = BOF_THREAD_PRIORITY_000;
MaxPendingRequest_U32 = 0;
Expand Down Expand Up @@ -89,6 +93,7 @@ using BOF_MULTICAST_ASYNC_NOTIFY_FCT = void (*)(const T *_pNotifyArg);

struct BOF_MULTICAST_ASYNC_NOTIFIER_PARAM
{
bool PriorityInversionAware_B;
uint64_t ThreadCpuCoreAffinityMask_U64;
BOF_THREAD_SCHEDULER_POLICY ThreadSchedulerPolicy_E;
BOF_THREAD_PRIORITY ThreadPriority_E;
Expand All @@ -100,6 +105,7 @@ struct BOF_MULTICAST_ASYNC_NOTIFIER_PARAM
}
void Reset()
{
PriorityInversionAware_B = false;
ThreadCpuCoreAffinityMask_U64 = 0;
ThreadSchedulerPolicy_E = BOF_THREAD_SCHEDULER_POLICY_OTHER;
ThreadPriority_E = BOF_THREAD_PRIORITY_000;
Expand All @@ -123,7 +129,7 @@ class BofMulticastAsyncNotifier
BOFERR WaitForNoMoreNotificationPending(uint32_t _PollTimeInMs_U32, uint32_t _TimeoutInMs_U32);

private:
BofMsgThread mMsgThread;
std::unique_ptr<BofMsgThread> mpuMsgThread=nullptr;
DelegateLib::MulticastDelegateSafe1<const T *> mMulticastDelegate;
};

Expand All @@ -132,7 +138,8 @@ BofMulticastAsyncNotifier<T>::BofMulticastAsyncNotifier(const BOF_MULTICAST_ASYN
{
BOFERR Sts_E;

Sts_E = mMsgThread.LaunchBofProcessingThread("BofAsyncNotif", false, 0, _rAsyncNotifierParam_X.ThreadSchedulerPolicy_E, _rAsyncNotifierParam_X.ThreadPriority_E, _rAsyncNotifierParam_X.ThreadCpuCoreAffinityMask_U64, 2000, 0);
mpuMsgThread = std::make_unique<BofMsgThread>(_rAsyncNotifierParam_X.PriorityInversionAware_B);
Sts_E = mpuMsgThread->LaunchBofProcessingThread("BofAsyncNotif", false, 0, _rAsyncNotifierParam_X.ThreadSchedulerPolicy_E, _rAsyncNotifierParam_X.ThreadPriority_E, _rAsyncNotifierParam_X.ThreadCpuCoreAffinityMask_U64, 2000, 0);
BOF_ASSERT(Sts_E == BOF_ERR_NO_ERROR);
}
template <class T>
Expand All @@ -143,7 +150,7 @@ BofMulticastAsyncNotifier<T>::~BofMulticastAsyncNotifier()
template <class T>
uint32_t BofMulticastAsyncNotifier<T>::NbPendingNotification()
{
return mMsgThread.GetNbPendingRequest();
return mpuMsgThread->GetNbPendingRequest();
}

template <class T>
Expand All @@ -154,8 +161,7 @@ BOFERR BofMulticastAsyncNotifier<T>::Register(BOF_MULTICAST_ASYNC_NOTIFY_FCT<T>
if (_pNotifyFct)
{
Rts_E = BOF_ERR_NO_ERROR;
auto Delegate = MakeDelegate(_pNotifyFct, &mMsgThread);
;
auto Delegate = MakeDelegate(_pNotifyFct, mpuMsgThread.get());
Delegate.UserContext(_pUserContext);
mMulticastDelegate += Delegate;
}
Expand All @@ -169,7 +175,7 @@ BOFERR BofMulticastAsyncNotifier<T>::Unregister(BOF_MULTICAST_ASYNC_NOTIFY_FCT<T
if (_pNotifyFct)
{
Rts_E = BOF_ERR_NO_ERROR;
mMulticastDelegate -= MakeDelegate(_pNotifyFct, &mMsgThread);
mMulticastDelegate -= MakeDelegate(_pNotifyFct, mpuMsgThread.get());
}
return Rts_E;
}
Expand Down Expand Up @@ -202,7 +208,7 @@ BOFERR BofMulticastAsyncNotifier<T>::WaitForNoMoreNotificationPending(uint32_t _
Rts_E = BOF_ERR_FULL;
do
{
if (mMsgThread.GetNbPendingRequest() == 0)
if (mpuMsgThread->GetNbPendingRequest() == 0)
{
Rts_E = BOF_ERR_NO_ERROR;
break;
Expand Down
48 changes: 0 additions & 48 deletions lib/include/bofstd/bofbit.h.bak

This file was deleted.

Loading

0 comments on commit 29b8b3c

Please sign in to comment.