Now,each request will open a connection.
I want to do a ConnectionPool. The SqlService only fetch connection from Actor.locals, so don't share the connection.
ConnectionPool
SqlService
Actor.locals
I have no idea.
Thanks.
You want to share a connection across actors? I don't believe that most jdbc drivers are thread-safe, so how would that work?
like this:
class ConectionPool:Actor{ Connection _pop(){ connList.pop } Connection pop(){ send(#_pop).get } Void _push(conn){ conn.toOriginalState connList.push(conn) } } class sqlService{ ConectionPool pool Void open(){ Connection? conn := Actor.locals[id] if (conn == null){ Actor.locals[id] = pool.pop }else{ conn.increment } } Void close(){ Connection? conn := Actor.locals[id] if (conn != null){ if (conn.decrement == 0){ Actor.locals[id]=null pool.push(conn) } } } }
It's accessed by one thread at the same time.
Maybe I will rewrite SqlService by my way.
Recently,I am making a simple ORM tool.It's here slan
Login or Signup to reply.
go4 Sun 3 Oct 2010
Now,each request will open a connection.
I want to do a
ConnectionPool
. TheSqlService
only fetch connection fromActor.locals
, so don't share the connection.I have no idea.
Thanks.
brian Tue 5 Oct 2010
You want to share a connection across actors? I don't believe that most jdbc drivers are thread-safe, so how would that work?
go4 Tue 5 Oct 2010
like this:
It's accessed by one thread at the same time.
go4 Wed 6 Oct 2010
Maybe I will rewrite
SqlService
by my way.Recently,I am making a simple ORM tool.It's here slan