Memvars and Multi Threading
Posted: Sat Jan 12, 2019 11:14 am
Hi folks,
We are currently working on the implementation of the Memvar support in the runtime.
One question that we have is what to do with memvars and multi threading.
For PRIVATE memvars things are kind of obvious: since privates are visible in a function/method and the functions/methods called from this function, this automatically means that each thread will have its own privates "stack", similar to how each thread has its own local variables.
For PUBLICS however we have a choice: either they are shared between threads or each new thread gets its own copy of the PUBLICS list.
At this moment we are considering to make the PUBLICs shared between threads, just like GLOBALs.
We will handle the locking in the runtime, so you should not have to worry about that.
And this is different for GLOBALs where you need to handle the locking yourself.
Does this make sense ?
Are we overlooking something?
Robert
PS We are trying to implement memvar support with minimal impact on performance. When you are not using them at all then you will not be 'punished' by this new feature. At this moment we want to support them in the VO , XBase++ and Harbour dialect only (so not for Vulcan and Core). We are considering to also add a special compiler option that has to be set to enable the memvar support.
We are currently working on the implementation of the Memvar support in the runtime.
One question that we have is what to do with memvars and multi threading.
For PRIVATE memvars things are kind of obvious: since privates are visible in a function/method and the functions/methods called from this function, this automatically means that each thread will have its own privates "stack", similar to how each thread has its own local variables.
For PUBLICS however we have a choice: either they are shared between threads or each new thread gets its own copy of the PUBLICS list.
At this moment we are considering to make the PUBLICs shared between threads, just like GLOBALs.
We will handle the locking in the runtime, so you should not have to worry about that.
And this is different for GLOBALs where you need to handle the locking yourself.
Does this make sense ?
Are we overlooking something?
Robert
PS We are trying to implement memvar support with minimal impact on performance. When you are not using them at all then you will not be 'punished' by this new feature. At this moment we want to support them in the VO , XBase++ and Harbour dialect only (so not for Vulcan and Core). We are considering to also add a special compiler option that has to be set to enable the memvar support.