[Gambas-devel] Question about singleton class

Tobias Boege taboege at ...176...
Wed Sep 10 20:45:52 CEST 2014


On Wed, 10 Sep 2014, John Leake wrote:
> > 
> > What for? The interpreter is not multi-threaded.
> > 
> I am looking for a system wide singleton with guaranteed mutual
> exclusion to any executable written in Gambas.
> 

As if all instances of the interpreter (i.e. independent processes) on a
system were just (well-behaved) threads of one instance? You want to use
the *same* object in *all* interpreters -- but of course access it mutually
exclusively? Some kind of persistent object which does not belong to a single
process and would be deallocated when that process terminates, but an object
which survives until the last of all Gambas interpreters gets killed (or even
survive that, too)?

That's definitely not built into Gambas. Maybe you can try to shm_open()
some memory and hack the interpreter to allocate your object and all objects
it ever references (doesn't sound that easy) in that shared memory region. If
you got there, it should be no big deal to have the "mutually exclusive" part
by using pthreads or futex.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the Devel mailing list