Was up late last night experimenting, and succeded in the following.
Making my $foo : ishared; work
It ties to a iThread::Share variable which stores the scalar and mutex protects it.
lock($foo) and unlock($foo)
Locks the mutex of the iThread::Share structure, replaces perls builtin lock and unlock. Unfournatly it does not automaticly unlock when the lock goes out of scope, it would be nice to do so, but it requires modifying the callers context and inserting the lock object there, however I am NOT going to do that yet.
The threadsafe version of localtime is around 100% slower than plain localtime(), so if it is a real problem I guess we have to fix it and use localtime_r, but that is not something I can do and this works for the time being.
iThread::Safe::localtime()
This implments a threadsafe wrapper around localtime and installs it into CORE::GLOBAL. It is protected by a shared variable that it mutexes on. This worked threadsafly
All of these efforts are part of my effort to make iThreads work without modifying the core. I think that is essential to the ability to get them adopted, if in the future optimizations can be done by adding code to the core, perhaps that could be done.
On my todo now.
Cheers! Artur