<br>Vance,<div>Thank you very much. but it really not.</div><div><div>=====================</div><div><div>= code</div><div>=====================</div><div>-module(taskq).</div><div>-export([start/0, db_put/1, db_get/0]).</div>
<div><br></div><div><br></div><div>-record(oid, {name, id}).</div><div>-record(task, {id, info}).</div><div><br></div><div>start()-></div><div> </div><div> mnesia:start(),</div><div> try</div><div> mnesia:table_info(task, type)</div>
<div> catch</div><div> exit: _ -></div><div> mnesia:stop(),</div><div> mnesia:create_schema([node()]),</div><div> </div><div> mnesia:start(),</div><div> mnesia:create_table(oid, [{disc_copies, [node()]}, {type, set}, {attributes, record_info(fields, oid)}]),</div>
<div> mnesia:create_table(task, [{disc_copies, [node()]}, {type, ordered_set}, {attributes, record_info(fields, task)}]),</div><div> </div><div> mnesia:transaction(fun()-></div><div> mnesia:write(#oid{name = task, id = 0})</div>
<div> end) </div><div> end.</div><div><br></div><div>db_put(Info)-> </div><div> mnesia:transaction(fun()-></div><div> Id = mnesia:dirty_update_counter({oid, task}, 1),</div><div> mnesia:write(#task{id = Id, info = Info})</div>
<div> end).</div><div><br></div><div>db_get()-></div><div> {atomic, R} = mnesia:transaction(fun()-></div><div> Id = mnesia:first(task),</div><div> case Id of</div><div> '$end_of_table' -></div>
<div> none;</div><div> _ -></div><div> [Ret] = mnesia:wread({task, Id}),</div><div> mnesia:delete({task, Id}),</div><div> Ret#<a href="http://task.info">task.info</a></div>
<div> end</div><div> end),</div><div> R.</div><div><br></div><div><div>=====================</div><div>= exection</div><div>=====================</div><div><div>Linan-iMac:~ wangii$ erl</div><div>Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [kernel-poll:false]</div>
<div><br></div><div>Eshell V5.6.5 (abort with ^G)</div><div>1> c(taskdb). </div></div></div><div><div>error</div><div>2> c(taskq).</div><div>{ok,taskq}</div><div>3> taskq:start().</div><div><br></div><div>=INFO REPORT==== 22-Nov-2008::17:07:20 ===</div>
<div> application: mnesia</div><div> exited: stopped</div><div> type: temporary</div><div>{atomic,ok}</div><div>4> taskq:put(abcdefa).</div><div>** exception error: undefined function taskq:put/1</div><div>5> taskq:db_put(abcdefa).</div>
<div>{atomic,ok}</div><div>6> </div><div>BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded</div><div> (v)ersion (k)ill (D)b-tables (d)istribution</div><div>q</div><div>Linan-iMac:~ wangii$ erl</div><div>Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [kernel-poll:false]</div>
<div><br></div><div>Eshell V5.6.5 (abort with ^G)</div><div>1> taskq:start().</div><div>ordered_set</div><div>2> taskq:db_get().</div><div>none</div><div>3> </div><div><br></div></div><div class="gmail_quote">On Sat, Nov 22, 2008 at 4:40 PM, Vance Shipley <span dir="ltr"><<a href="mailto:vances@motivity.ca">vances@motivity.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Linan,<br>
<br>
I tried your sample code and confirmed the behaviour you reported.<br>
Then I changed mnesia:s_write/1 to mnesia:write/1 and it worked as<br>
expected.<br>
<font color="#888888"><br>
-Vance<br>
</font><div><div></div><div class="Wj3C7c"><br>
On Sat, Nov 22, 2008 at 04:32:52PM +0000, Linan Wang wrote:<br>
} thanks for the suggestion.I changed all s_write, wread, s_delete to<br>
} straightforward write, read, delete. it does not help.<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Best regards<br><br>Linan Wang<br>
</div></div>