diff options
| author | Pietro Gagliardi <[email protected]> | 2014-07-28 20:52:32 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-07-28 20:52:32 -0400 |
| commit | 7cb6ca1243fd12fe942964c3ffbfa6a9bb80caeb (patch) | |
| tree | 1230d24c4c692feed9125e3e34664ebaeb5ad302 /redo/table.go | |
| parent | e2ef204b706b308090d1a1b6f3161458dcb99b0e (diff) | |
Began the implementation of Table on Windows.
Diffstat (limited to 'redo/table.go')
| -rw-r--r-- | redo/table.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/redo/table.go b/redo/table.go index 52024da..7a0e174 100644 --- a/redo/table.go +++ b/redo/table.go @@ -13,6 +13,8 @@ import ( // Tables maintain their own storage behind a sync.RWMutex-compatible sync.Locker; use Table.Lock()/Table.Unlock() to make changes and Table.RLock()/Table.RUnlock() to merely read values. // TODO headers type Table interface { + Control + // Lock and Unlock lock and unlock Data for reading or writing. // RLock and RUnlock lock and unlock Data for reading only. // These methods have identical semantics to the analogous methods of sync.RWMutex. @@ -41,16 +43,18 @@ func NewTable(ty reflect.Type) Table { panic(fmt.Errorf("unknown or unsupported type %v given to NewTable()", ty)) } b := new(tablebase) - // arbitrary starting capacity - b.data = reflect.NewSlice(ty, 0, 512).Addr().Interface() - return finishNewTable(b) + // we want a pointer to a slice + b.data = reflect.New(reflect.SliceOf(ty)).Interface() + return finishNewTable(b, ty) } func (b *tablebase) Lock() { b.lock.Lock() } -func (b *tablebase) Unlock() { +// Unlock() is defined on each backend implementation of Table +// they should all call this, however +func (b *tablebase) unlock() { b.lock.Unlock() } @@ -62,6 +66,6 @@ func (b *tablebase) RUnlock() { b.lock.RUnlock() } -func (b *tablebase) Data() { +func (b *tablebase) Data() interface{} { return b.data } |
