Version française
Home     About     Download     Resources     Contact us    
Browse thread
Can GC be BLOCKed?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris King <colanderman@g...>
Subject: Re: [Caml-list] Can GC be BLOCKed?
On 12/1/06, Neal Wang <neal.wang@gmail.com> wrote:
> The problem is that:
>  When an object is being loaded through an "sql" select stmt, GC is
> then invoked to reclaim memory which will in turn call finalise
> functions to store some objects into db.  At this moment, the db has
> been locked by the select stmt, and the storing procedure fails.  The
> problem is due to sqlite3 doesn't provide row level locks.  A simple
> solution is to prevent GC from calling finalise functions whenever we
> are loading an object into memory.

Have you thought about simply postponing the write-back until the
database is unlocked?  If the finalization function finds that the
database is locked, it can place the data to be written into a global
queue.  (This is possible because finalization functions in O'Caml are
allowed to make their data reachable again.)  This queue can then be
flushed when the database is unlocked.  You could easily extend this
to support queueing of any operation by queueing functions instead of
data.

Hope this helps!

- Chris King