I’m sorry, Tony, but I’m not a fan of the idea of IP variables behaving 
differently in different contexts. I haven’t actually used preemptive processes 
yet, but I’ve been studying them as I plan to use them in a few different 
contexts in a new project I’m on once I get to that point.

I’ve been looking at where I would like to use IP variables in preemptive 
processes. In pretty much every case I have some information (usually parallel 
arrays or a c_object) that I fill once at startup from somewhere (a file, 
tables, the internet, calculated, etc.) that I need access to in other 
processes. But these IP variables are never changed after startup. Does this 
align with what other people do?

I’ve thought of two possible solutions. The first is simply to cache this 
information in the datafile somewhere and pull from there when needed. 
Hopefully it is in 4D's cache and will be quick to access. This assumes we are 
on the server which is true for now, but won’t be true if/when 4D allows 
preemptive processes on the client.

The other solution would be to have 4D introduce the idea of a static variable. 
So if I declared an interprocess variable the normal way, it would not be 
allowed in preemptive processes. But if it was declared as static, then it is 
only read only for any process once it is set so I assume that a preemptive 
process could read this variable without issue. This would solve most of my 
issues with interprocess variables in preemptive processes.

I do agree that it would be nice if 4D threw an error at runtime instead of 
relying on compile time checks if an unsafe command was used in a preemptive 
process. At least, I agree with that as long as doing it this way isn’t slower. 
I guess that depends on how the internal checks are made. But that would make 
it possible to have different code paths in the same method.

Finally, I actually wish that it was possible to surround thread unsafe code in 
a semaphore in a preemptive process. This should be discouraged, but I don’t 
see why it should be completely disallowed. There are exceptions to every rule, 
it seems, and I think there will be cases where it is worth the slight slow 
down in code to run some thread unsafe code.

But my biggest hope is that we can have the concept of static-ly defined 
variables, especially arrays and objects. Would this solve similar issues for 
other people?

--
Cannon Smith
Synergy Farm Solutions Inc.
Hill Spring, AB Canada
403-626-3236
<can...@synergyfarmsolutions.com>
<www.synergyfarmsolutions.com>

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to