[erlang-questions] How to the a ets table is exists or not ?

tatezhou@REDACTED tatezhou@REDACTED
Mon Mar 17 05:09:33 CET 2008

Code pieces " Ret = ets:new(client_cmd_hooks, [named_table])" is just a example.

In actuall evnviroments, We need to create different type tables. Some of them  is public  , which means all procees can access it. It is like "golbal variable" . Some of them is owned by specific process.  

For the public table, The best design is to create them in the supervised process who will star child module, so all the child modlue can access the table. 

But some times, i need to follow the orginal design structure, so , i have to create public table in child module for avoiding change the "parent" level code. If the "create table" code wrote in child modlue, it may be execute more than one time and cause error when the table alread exists.  

Any ideas for this issue?

Yes , 

----- Original Message ----- 
From: "Christian S" <chsu79@REDACTED>
To: <tatezhou@REDACTED>
Cc: <erlang-questions@REDACTED>
Sent: Saturday, March 15, 2008 7:36 PM
Subject: Re: [erlang-questions] How to the a ets table is exists or not ?

> 2008/3/15 tatezhou@REDACTED <tatezhou@REDACTED>:
>> I need to create a ets table if it is not exists, how to code it ?  I have
>> check the online docs of chapter "ets", there is not function to handle this
>> Current solution is to get all the ets tables and check if the table i want
>> in the list. but i  don't think this is a good idea.
>> Ret = ets:new(client_cmd_hooks, [named_table]),
> Overall this seem a bit weird designed.
> Who will be the designated ets table owner for this named table? First
> arriving process to need the table to exist?
> Why is it not created at start up by a supervised owner in your
> application? If your application is running, the table is there, if
> your application crashes, the owner will be restarted and create it
> anew.

More information about the erlang-questions mailing list