Home > Archive > Smalltalk > February 2006 > [VW] Processes
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Ian Upright 2006-02-25, 3:57 am |
| Lets say I need to associate some data with a VW processes.. such as a small
integer to represent an ID, perhaps which has nothing to do with any
VisualWorks id that this process thread may have. Now this id needs to be
passed to each and every DLLCC call it makes.
There are likely a multitude of different ways of implementing this -- my
question is, what is the most efficient way of doing it? (I'm even open to
having the external function call back into the VM if that could help)
Can I safely add an instance variable to a Process? (seems gross) Any
better ways?
Ian
---
http://www.upright.net/ian/
| |
| Reinout Heeck 2006-02-25, 6:59 pm |
| Ian Upright wrote:
> Lets say I need to associate some data with a VW processes.. such as a
> small integer to represent an ID, perhaps which has nothing to do with any
> VisualWorks id that this process thread may have. Now this id needs to be
> passed to each and every DLLCC call it makes.
>
> There are likely a multitude of different ways of implementing this -- my
> question is, what is the most efficient way of doing it? (I'm even open
> to having the external function call back into the VM if that could help)
Most efficient would be to pass the OOP of the Process (on the Smalltalk
side that would look like passing the Process itself). I'm not sure how
long an OOP is stable though (memory compaction).
> Can I safely add an instance variable to a Process? (seems gross) Any
> better ways?
Yes, to support MultiProcUI and PDP several ivars have been added.
As it happens one of them (environment) holds a property dictionary, so you
could put your ID there without adding an ivar to Process. Accessing this
environment is slow though, it has to go through a #critical: section.
You could also use an auxiliary Dictionary to record process->id mappings,
for this you may want to look into MethodDictionary which is designed to be
read from C code as well as from Smalltalk.
HTH,
Reinout
-------
|
|
|
|
|