[go-nuts] Re: Windows Message Loop is getting blocked and resumed intermittently

2017-02-16 Thread martseniuk
Oh! Sorry about the wrong link. 
However dont ignore 2 errors from ole.GetMessage & ole.DispatchMessage

On Thursday, February 16, 2017 at 1:45:18 PM UTC+3, fe f wrote:
>
>
> https://github.com/go-ole/go-ole/blob/master/com.go#L308
>
> I used this function. 
>
> 2017년 2월 16일 목요일 오후 1시 30분 11초 UTC+9, marts...@gmail.com 님의 말:
>>
>> check ole.GeMessage error.
>>
>> btw. https://github.com/go-ole/go-ole/blob/master/com_func.go#L163
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Windows Message Loop is getting blocked and resumed intermittently

2017-02-16 Thread fe f

https://github.com/go-ole/go-ole/blob/master/com.go#L308

I used this function. 

2017년 2월 16일 목요일 오후 1시 30분 11초 UTC+9, marts...@gmail.com 님의 말:
>
> check ole.GeMessage error.
>
> btw. https://github.com/go-ole/go-ole/blob/master/com_func.go#L163
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Windows Message Loop is getting blocked and resumed intermittently

2017-02-15 Thread martseniuk
check ole.GeMessage error.

btw. https://github.com/go-ole/go-ole/blob/master/com_func.go#L163

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Windows Message Loop is getting blocked and resumed intermittently

2017-02-15 Thread martseniuk
check ole.GeMessage error.

btw. https://github.com/go-ole/go-ole/blob/master/com_func.go#L163

On Thursday, February 16, 2017 at 7:12:19 AM UTC+3, fe f wrote:
>
> I'm writing a go program that constantly receives and processes windows 
> messages in golang. (Go1.7, GOMAXPROCS=8, Windows 10)
>
> Here's my code.. (minimal code)
>
> import (
> "fmt"
> "github.com/go-ole/go-ole"
> "runtime"
> )
> func main () {
> SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS)
> runtime.LockOSThread()
>
>
> InitCOM() // Initializes COM Object 
> // (The com object constantly send message to this process)
>
>
> RunTickerGoroutine() 
> // This functions internally launches one goroutine, 
> // which also sends message to the main thread every 30 seconds
>
>
>
>
> /* Typical Windows Message Loop */
> var m ole.Msg
> for {
> ole.GetMessage(&m, 0, 0, 0)
> fmt.Println(m, ": Got Message!")
> ole.DispatchMessage(&m)
> }
> }
>
>
> func SetPriorityClass() {
>// Just some some syscalls calling SetPriorityClass of Kernel32.dll
>... 
> }
>
>
>
> So bascially there are two objects(com object and goroutine I launched) 
> which constantly send messages to the main goroutine and this main 
> goroutine processes them with typical message loop.. and it works well most 
> of the time.
>
> However, the problem is, sometimes the message loop is getting blocked, 
> and after some amount of time, the message loop resumes and large amount of 
> blocked old messages are getting pumped.
>
> I initially thought this is because of main goroutine's OS Thread 
> switching. 
> I thought windows message loop is not getting any message for a while 
> because it's goroutine got switched to other OS Thread for a while. 
>
> So I added a code runtime.LockOSThread() like above code. But the problem 
> still occurred! 
>
> So I thought this is probably because of OS Context Switch.. 
> So I added code SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS) 
> to ensure this process to be high priority in windows, and killed all of 
> other cpu intensive processes.
> But the problem still occurred.
>
> I really have no idea how to solve this problem.. 
>
> Now I'm suspecting that runtime go scheduler is not scheduling my main 
> goroutine(message loop thread) sometimes, and that's why my message loop 
> get blocked for a while.
>
> However, I have no idea how to verify it and also solve it.
>
> So my question is.. 
>
> Why the message loop is getting blocked intermittently?
>
> How can I solve this problem? (I want my main goroutine(message loop) 
> always working without OS Thread switch (never blocked))
>
> Any helps/ideas will be greatly appreciated. Thanks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.