2013/5/20 Dominik Charousset
In any case, we would no longer be able to converts threads to actors on-the-fly: Humm, this would be unfortunate. int main() { auto worker = spawn(...); // Um... what is the type of 'self'? Is it a valid receiver for the response message? send(worker, ...); receive ( // again: what is 'self' allowed to receive/reply? ... ); } Couldn't spawn have a template parameter giving the provided protocol? Self could be typed with the supported protocol(s). Self could be passed by the underlying system as a parameter of the spawned function, as e.g. Boost.Coroutine does. This avoids the use of thread specific data to get the current self as I expect you do. Up to the user to manage with the self parameter.
The 'self' pointer has to use a thread-local variable, because (1) scheduled actors migrate between threads (see Oliver Kowalke's response) and (2) threads are converted implicitly as soon as they use actor-related messages such as 'send'.
What I tried to say - it will not work because compilers are allowed to do some optimizations with addresses of thread-local data.