Skip to content

Commit

Permalink
Add a note about glib.IdleAddOnce in documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
pekim committed Dec 30, 2018
1 parent 256761b commit d961df8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
20 changes: 20 additions & 0 deletions docs-src/content/goroutines.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ To perform such a call from a goroutine,
use `glib.IdleAdd` to schedule invocation of a
callback function on the main thread.

## `IdleAdd`

```go
glib.IdleAdd(func() bool {
someLabel.SetText("some text")
Expand All @@ -21,3 +23,21 @@ Return `glib.SOURCE_REMOVE` to ensure the function is not
called again next time the main loop is idle.
Alternatively return `glib.SOURCE_CONTINUE` to have
the function called again.

## `IdleAddOnce`

Alternatively, `glib.IdleAddOnce`
schedules a _single_ invocation of a
callback function on the main thread.
Unlike `glib.IdleAdd` no value needs to be returned
to avoid subsequent invocations of the callback.


```go
glib.IdleAddOnce(func() {
someLabel.SetText("some text")
})
```

`IdleAddOnce` is a convenience provided by gobbi.
It has no direct equivalent in the glib C library.
19 changes: 18 additions & 1 deletion docs/goroutines/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/glib/main_event_loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ sources after one invocation. That is, the callback will only be called once.
func IdleAddOnce(callback IdleAddOnceCallback) {
IdleAdd(func() bool {
callback()
return false
return SOURCE_REMOVE
})
}

Expand Down

0 comments on commit d961df8

Please sign in to comment.