MCPcopy
hub / github.com/ebitengine/oto / newCOMThread

Function newCOMThread

driver_wasapi_windows.go:35–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33}
34
35func newCOMThread() (*comThread, error) {
36 funcCh := make(chan func())
37 errCh := make(chan error)
38 go func() {
39 runtime.LockOSThread()
40 defer runtime.UnlockOSThread()
41
42 // S_FALSE is returned when CoInitializeEx is nested. This is a successful case.
43 if err := windows.CoInitializeEx(0, windows.COINIT_MULTITHREADED); err != nil && !errors.Is(err, syscall.Errno(windows.S_FALSE)) {
44 errCh <- err
45 }
46 // CoUninitialize should be called even when CoInitializeEx returns S_FALSE.
47 defer windows.CoUninitialize()
48
49 close(errCh)
50
51 for f := range funcCh {
52 f()
53 }
54 }()
55
56 if err := <-errCh; err != nil {
57 return nil, err
58 }
59
60 return &comThread{
61 funcCh: funcCh,
62 }, nil
63}
64
65func (c *comThread) Run(f func()) {
66 ch := make(chan struct{})

Callers 1

newWASAPIContextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…