Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"09-18-13 - Per-Thread Global State Overrides"

2 Comments -

1 – 2 of 2
Blogger bionic said...

I've used this approach and it works really well until you start building stuff using jobs/tasks. At that point what you really want is state associated with the job group since the scheduler will most likely reuse threads to join in on other work while a task is blocked.

Unfortunately this is not always easy to implement efficiently, like when you're using a thirdparty framework like ConcRT (see http://stackoverflow.com/questions/12882719/implementing-task-local-variables-for-concurrency-runtime for example)

Obviously you can "solve" this by explicitly passing all state around, but it gets tedious real quick for certain stuff (like the log in your example).

September 21, 2013 at 1:53 AM

Blogger cbloom said...

I think that in these task-based frameworks one of the first things you have to do is make a TLS replacement.

I guess the most general way to do that is to have every Task take a "State *" as argument, and then every single function in your code has to take "State *" as one of its arguments. That you can find local vars in the State.

September 22, 2013 at 10:18 AM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.