Settled race condition TODOs across all platforms... as an unfortunate case :(

This commit is contained in:
Pietro Gagliardi 2014-08-11 14:16:23 -04:00
parent 5d4fd8169b
commit b198a4dfec
3 changed files with 29 additions and 17 deletions

View File

@ -36,11 +36,15 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table {
func (t *table) Unlock() { func (t *table) Unlock() {
t.unlock() t.unlock()
// TODO RACE CONDITION HERE // there's a possibility that user actions can happen at this point, before the view is updated
// not sure about this one... // alas, this is something we have to deal with, because Unlock() can be called from any thread
t.RLock() go func() {
defer t.RUnlock() Do(func() {
C.tableUpdate(t._id) t.RLock()
defer t.RUnlock()
C.tableUpdate(t._id)
})
}()
} }
//export goTableDataSource_getValue //export goTableDataSource_getValue

View File

@ -58,13 +58,17 @@ func (t *table) Lock() {
func (t *table) Unlock() { func (t *table) Unlock() {
t.unlock() t.unlock()
// TODO RACE CONDITION HERE // there's a possibility that user actions can happen at this point, before the view is updated
// not sure about this one... // alas, this is something we have to deal with, because Unlock() can be called from any thread
t.RLock() go func() {
defer t.RUnlock() Do(func() {
d := reflect.Indirect(reflect.ValueOf(t.data)) t.RLock()
new := C.gint(d.Len()) defer t.RUnlock()
C.tableUpdate(t.model, t.old, new) d := reflect.Indirect(reflect.ValueOf(t.data))
new := C.gint(d.Len())
C.tableUpdate(t.model, t.old, new)
})
}()
} }
//export goTableModel_get_n_columns //export goTableModel_get_n_columns

View File

@ -38,11 +38,15 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table {
func (t *table) Unlock() { func (t *table) Unlock() {
t.unlock() t.unlock()
// TODO RACE CONDITION HERE // there's a possibility that user actions can happen at this point, before the view is updated
// I think there's a way to set the item count without causing a refetch of data that works around this... // alas, this is something we have to deal with, because Unlock() can be called from any thread
t.RLock() go func() {
defer t.RUnlock() Do(func() {
C.tableUpdate(t._hwnd, C.int(reflect.Indirect(reflect.ValueOf(t.data)).Len())) t.RLock()
defer t.RUnlock()
C.tableUpdate(t._hwnd, C.int(reflect.Indirect(reflect.ValueOf(t.data)).Len()))
})
}()
} }
//export tableGetCellText //export tableGetCellText