Allow calling LLNotificationsUtil::add from any thread.
This makes LLStringUtil thread-safe by removing a rather unnecessary LLFastTimer from LLStringUtil::format. Same thing for LLTrans::getString and LLTrans::findString, where even a comment stated that the author wasn't interested in measuring cpu time at all. In this case I added some code back to make sure that we're not calling LLTrans::getString() in an inner loop, which was the reason that the LLFastTimer was added. Made one string static to avoid 45000 look ups during login, which kinda triggered the above test. Finally, LLNotificationsUtil::add is made thread-safe by making LLNotificationChannelBase::mItems thread-safe and defering a call to LLNotifications::updateItem to the main thread when called from another thread (using a little statemachine).
This commit is contained in:
@@ -107,6 +107,7 @@
|
||||
#include "llxmlnode.h"
|
||||
#include "llnotificationptr.h"
|
||||
#include "llnotificationcontext.h"
|
||||
#include "aithreadsafe.h"
|
||||
|
||||
namespace AIAlert { class Error; }
|
||||
|
||||
@@ -196,6 +197,7 @@ class LLNotification :
|
||||
{
|
||||
LOG_CLASS(LLNotification);
|
||||
friend class LLNotifications;
|
||||
friend class UpdateItem;
|
||||
|
||||
public:
|
||||
// parameter object used to instantiate a new notification
|
||||
@@ -566,9 +568,10 @@ class LLNotificationChannelBase :
|
||||
public boost::signals2::trackable
|
||||
{
|
||||
LOG_CLASS(LLNotificationChannelBase);
|
||||
friend class UpdateItem;
|
||||
public:
|
||||
LLNotificationChannelBase(LLNotificationFilter filter, LLNotificationComparator comp) :
|
||||
mFilter(filter), mItems(comp)
|
||||
mFilter(filter), mItems_sf(comp)
|
||||
{}
|
||||
virtual ~LLNotificationChannelBase() {}
|
||||
// you can also connect to a Channel, so you can be notified of
|
||||
@@ -582,7 +585,9 @@ public:
|
||||
const LLNotificationFilter& getFilter() { return mFilter; }
|
||||
|
||||
protected:
|
||||
LLNotificationSet mItems;
|
||||
AIThreadSafeSimpleDC<LLNotificationSet> mItems_sf;
|
||||
typedef AIAccess<LLNotificationSet> mItems_wat;
|
||||
typedef AIAccessConst<LLNotificationSet> mItems_crat;
|
||||
LLStandardSignal mChanged;
|
||||
LLStandardSignal mPassedFilter;
|
||||
LLStandardSignal mFailedFilter;
|
||||
|
||||
Reference in New Issue
Block a user