-
Notifications
You must be signed in to change notification settings - Fork 0
/
runnable.go
28 lines (24 loc) · 854 Bytes
/
runnable.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package cronet
// #include <stdlib.h>
// #include <stdbool.h>
// #include <cronet_c.h>
import "C"
// Runnable is an interface to run commands on the Executor.
//
// Note: In general creating Runnables should only be done by Cronet. Runnables
// created by the app don't have the ability to perform operations when the
// Runnable is being destroyed (i.e. by Cronet_Runnable_Destroy) so resource
// leaks are possible if the Runnable is posted to an Executor that is being
// shutdown with unexecuted Runnables. In controlled testing environments
// deallocation of associated resources can be performed in Run() if the
// runnable can be assumed to always be executed.
// */
type Runnable struct {
ptr C.Cronet_RunnablePtr
}
func (r Runnable) Destroy() {
C.Cronet_Runnable_Destroy(r.ptr)
}
func (r Runnable) Run() {
C.Cronet_Runnable_Run(r.ptr)
}