Package mil.nga.geopackage.user
Class UserRowSync<TColumn extends UserColumn,TTable extends UserTable<TColumn>,TRow extends UserCoreRow<TColumn,TTable>>
- java.lang.Object
-
- mil.nga.geopackage.user.UserRowSync<TColumn,TTable,TRow>
-
- Type Parameters:
TColumn
- column typeTTable
- table typeTRow
- row type
public class UserRowSync<TColumn extends UserColumn,TTable extends UserTable<TColumn>,TRow extends UserCoreRow<TColumn,TTable>> extends Object
User Row Sync to support sharing a single user row read copy when multiple near simultaneous asynchronous requests are made- Since:
- 2.0.0
- Author:
- osbornb
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
UserRowSync.RowCondition
Condition and row wrapper
-
Constructor Summary
Constructors Modifier Constructor Description protected
UserRowSync()
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TRow
getRowOrLock(long id)
Get the row if another same id request has been made by waiting until the row has been set.void
setRow(long id, TRow row)
Set the row id, row, and notify all waiting threads to retrieve the row.
-
-
-
Field Detail
-
lock
protected Lock lock
Synchronous lock
-
rows
protected Map<Long,UserRowSync.RowCondition> rows
Mapping between row ids and row conditions
-
-
Method Detail
-
getRowOrLock
public TRow getRowOrLock(long id)
Get the row if another same id request has been made by waiting until the row has been set. If no current request, lock the for the calling thread which should read the row and callsetRow(long, UserCoreRow)
when complete.- Parameters:
id
- user row id- Returns:
- row if retrieved from a previous request, null if calling thread
should read row and set using
setRow(long, UserCoreRow)
-
setRow
public void setRow(long id, TRow row)
Set the row id, row, and notify all waiting threads to retrieve the row.- Parameters:
id
- user row idrow
- user row or null
-
-