forked from lix-project/lix
Wrap thread local in function for Cygwin
Fixes #1826. See #1352 for a previous instance of a similar change.
This commit is contained in:
parent
24b739817f
commit
be54f4a0b6
|
@ -22,7 +22,7 @@ struct DownloadRequest
|
|||
std::string mimeType;
|
||||
|
||||
DownloadRequest(const std::string & uri)
|
||||
: uri(uri), parentAct(curActivity) { }
|
||||
: uri(uri), parentAct(getCurActivity()) { }
|
||||
};
|
||||
|
||||
struct DownloadResult
|
||||
|
|
|
@ -6,7 +6,16 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
thread_local ActivityId curActivity = 0;
|
||||
static thread_local ActivityId curActivity = 0;
|
||||
|
||||
ActivityId getCurActivity()
|
||||
{
|
||||
return curActivity;
|
||||
}
|
||||
void setCurActivity(const ActivityId activityId)
|
||||
{
|
||||
curActivity = activityId;
|
||||
}
|
||||
|
||||
Logger * logger = makeDefaultLogger();
|
||||
|
||||
|
|
|
@ -77,7 +77,8 @@ public:
|
|||
virtual void result(ActivityId act, ResultType type, const Fields & fields) { };
|
||||
};
|
||||
|
||||
extern thread_local ActivityId curActivity;
|
||||
ActivityId getCurActivity();
|
||||
void setCurActivity(const ActivityId activityId);
|
||||
|
||||
struct Activity
|
||||
{
|
||||
|
@ -86,10 +87,10 @@ struct Activity
|
|||
const ActivityId id;
|
||||
|
||||
Activity(Logger & logger, Verbosity lvl, ActivityType type, const std::string & s = "",
|
||||
const Logger::Fields & fields = {}, ActivityId parent = curActivity);
|
||||
const Logger::Fields & fields = {}, ActivityId parent = getCurActivity());
|
||||
|
||||
Activity(Logger & logger, ActivityType type,
|
||||
const Logger::Fields & fields = {}, ActivityId parent = curActivity)
|
||||
const Logger::Fields & fields = {}, ActivityId parent = getCurActivity())
|
||||
: Activity(logger, lvlError, type, "", fields, parent) { };
|
||||
|
||||
Activity(const Activity & act) = delete;
|
||||
|
@ -121,8 +122,8 @@ struct Activity
|
|||
struct PushActivity
|
||||
{
|
||||
const ActivityId prevAct;
|
||||
PushActivity(ActivityId act) : prevAct(curActivity) { curActivity = act; }
|
||||
~PushActivity() { curActivity = prevAct; }
|
||||
PushActivity(ActivityId act) : prevAct(getCurActivity()) { setCurActivity(act); }
|
||||
~PushActivity() { setCurActivity(prevAct); }
|
||||
};
|
||||
|
||||
extern Logger * logger;
|
||||
|
|
Loading…
Reference in a new issue