Atomic ets

Rick Pettit <>
Tue Dec 13 18:35:35 CET 2005


On Tue, Dec 13, 2005 at 05:30:26PM +0100, Tony Rogvall wrote:
> 
> On 13 dec 2005, at 15.45, Thomas Lindgren wrote:
> 
> >
> >Now that we are getting a multithreaded runtime
> >system, is this a good time to bring up ets? I am
> >having some issues here.
> 
> For what it's worth I wrote a module called atomic.erl some time ago.  
> It can be regarded as
> lightweight but it uses ets and monitor heavily to avoid  
> synchronizing with a server process.
> 
> Could possibly be fun for some verifier to analyze, if not the flaws  
> are obvious ;-)
> 
> Also it can possibly be used to verify (if it works) that the ets is  
> multithread safe...
> 
> No documentation nor support is given ... (as always)
> 
> Typical use:
> 
> 	Key = foobar, %% could be any term
> 	atomic:lock(Key),
> 	do_something(),
> 	atomic:unlock(Key)
> 
> This can be condensed into atomic:exec(Key, fun() -> do_something()  
> end).
> 
> Note that the atomic needs a gen_server that owne the locker table to  
> work.
> 
> BTW the macro dbg_schedule can be used to verify if the atomic module  
> works,
> it forces context switches in some places.

Why not use global:trans/[234]?

-Rick



More information about the erlang-questions mailing list