Boost logo

Boost :

Subject: [boost] [coroutine][context] coroutine_specific_ptr proposal
From: Taylor Goodhart (Taylor.Goodhart_at_[hidden])
Date: 2012-04-19 12:38:25


With the context/coroutine library making great progress, in my mind it is
only natural to wonder whether something analogous to thread local storage
could be implemented for coroutines. I would propose using the existing
thread_specific_ptr as a starting point.

As for an initial design proposal, it seems to me like one could have a
single static atomic integer in the constructor of coroutine_specific_ptr
that is incremented for each new instance. This will allow each instance to
know their index, and to also know the total number of pointers. Then when
a new coroutine is created, a block of pointers of this size would be
created and placed before stack memory. If a coroutine were to try to
dereference a coroutine_specific_ptr then the index into this block would
be looked up and if NULL, create a new instance on the heap. If not NULL,
it would simply return the previously created value.

Comments and feedback would be appreciated. If this seems like something
people might use I'd be willing to take a crack at implementing it,
provided Oliver's blessing.

-Taylor Goodhart


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk