loop

Infinite windows message loop

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this message loop in my program: while (true) { if (PeekMessage(&msg, window, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { MessageBox(NULL, L"Quit", L"", 0); break; } TranslateMessage(&msg); DispatchMessage(&msg); } else { Render(); } } This loop never ends. It never displays the message box even though main window disappears. Here is the WndProc code: switch (msg) { case WM_CLOSE : DestroyWindow(hwnd); break; case WM_DESTROY : PostQuitMessage(0); break; default : return DefWindowProc(hwnd, msg, wParam, lParam); break; } return 0

Why is the Fortran DO loop index larger than the upper bound after the loop?

匿名 (未验证) 提交于 2019-12-03 02:35:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am looking inside the code of an air quality model written in fortran, and have some questions regarding the way fortran passes variables out from do-loops. This very simple example illustrates what I mean: PROGRAM carla IMPLICIT NONE ! INTEGER, PARAMETER :: LM = 24, DEZASSEIS = 16 INTEGER :: L, VARIAVEL, SOMA ! DO L=1,LM WRITE(*,*) 'L = ', L END DO ! WRITE(*,*) 'I am now ouside of the DO loop.' WRITE(*,*) 'I would expect L=LM=24... And SOMA=40' WRITE(*,*) 'L = ', L SOMA = DEZASSEIS + L WRITE(*,*) 'SOMA = ', SOMA END PROGRAM carla I would

MPMediaItemPropertyArtwork causes crash (weird issue)

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: allocations before running 'extra loop' The code: // loading items to the array, there are no memory warnings after this is completed. The first allocations screenshot is after this code and before extra loop code. NSMutableArray *albumCovers = [[NSMutableArray alloc] init]; for (MPMediaQuery *query in queries) { NSArray *allCollections = [query collections]; for (MPMediaItemCollection *collection in allCollections) { MPMediaItemArtwork *value = [collection.representativeItem valueForProperty:MPMediaItemPropertyArtwork]; UIImage *image =

python 3.5 asyncio and aiohttp Errno 101 Network is unreachable

匿名 (未验证) 提交于 2019-12-03 02:27:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using python 3.5 on Ubuntu 16. I am trying to use aiohttp to write a simple client. Here is the code I have. I took it from here . It's the first code sample, with ssl check disabled: import aiohttp import asyncio import async_timeout async def fetch(session, url): with async_timeout.timeout(10): async with session.get(url) as response: return await response.text() async def main(loop): conn = aiohttp.TCPConnector(verify_ssl=False) async with aiohttp.ClientSession(loop=loop, connector=conn) as session: html = await fetch(session, 'http:

No more data to read from socket

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My procedure looks like this: Declare cur_1 Sys_Refcursor; cur_2 Sys_Refcursor; v_1 VARCHAR2(30); v_2 VARCHAR2(30); v_3 VARCHAR2(30); v_4 VARCHAR2(30); Begin OPEN cur_1 for Select * from tab1@dblink1; Loop Fetch cur_1 into v_1, v_2; EXIT WHEN cur_1%NOTFOUND; OPEN cur_2 for Select * from tab2@dblink1 where col1 = v_1 and col2 = v2; Loop Fetch cur2 into v_3, v_4; Exit when cur_2%notfound; INSERT INTO local.tab3 values (v_1,v_2, v_3, v_4); END Loop; close cur_2; End Loop; close cur_1; END; The abobe procedure compiles, but when I run it I get

golang语言并发与并行——goroutine和channel的详细理解(一)

限于喜欢 提交于 2019-12-03 02:10:07
如果不是我对真正并行的线程的追求,就不会认识到 Go 有多么的迷人。 Go语言从语言层面上就支持了并发,这与其他语言大不一样,不像以前我们要用Thread库 来新建线程,还要用线程安全的队列库来共享数据。 以下是我入门的学习笔记。 Go语言的goroutines、信道和死锁 goroutine Go语言中有个概念叫做goroutine, 这类似我们熟知的线程,但是更轻。 以下的程序,我们串行地去执行两次 loop 函数: func loop () { for i := 0 ; i < 10 ; i ++ { fmt . Printf ( "%d " , i ) } } func main () { loop () loop () } 毫无疑问,输出会是这样的: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 下面我们把一个loop放在一个goroutine里跑,我们可以使用关键字 go 来定义并启动一个goroutine: func main () { go loop () // 启动一个goroutine loop () } 这次的输出变成了: 0 1 2 3 4 5 6 7 8 9 可是为什么只输出了一趟呢?明明我们主线跑了一趟,也开了一个goroutine来跑一趟啊。 原来,在goroutine还没来得及跑loop的时候,主函数已经退出了。

Go语言并发与并行--goroutine和channel和deadlock详解

﹥>﹥吖頭↗ 提交于 2019-12-03 02:07:26
概述 进程,线程的概念在操作系统的书上已经有详细的介绍。进程是内存资源管理和cpu调度的执行单元。为了有效利用多核处理器的优势,将进程进一步细分,允许一个进程里存在多个线程,这多个线程还是共享同一片内存空间,但cpu调度的最小单元变成了线程。 那协程又是什么东西,以及与线程的差异性? 协程,可以看作是轻量级的线程。但与线程不同的是,线程的切换是由操作系统控制的,而协程的切换则是由用户控制的。 最早支持协程的程序语言应该是lisp方言scheme里的continuation(续延),续延允许scheme保存任意函数调用的现场,保存起来并重新执行。Lua,C#,python等语言也有自己的协程实现。 Go语言从语言层面上就支持了并发,这与其他语言大不一样,不像以前我们要用Thread库 来新建线程,还要用线程安全的队列库来共享数据。 Go的goroutine goroutinue,本质上就是协程 。但也存在两点不同: goroutine可以实现并行,也就是说,多个协程可以在多个处理器上跑。而协程同一时刻只能在一个处理器上跑(把宿主语言想象成单线程就好了)。 goroutine之间通信是通过channel,而协程通信时通过yield和resume()操作。 以下的程序,我们串行地去执行两次 loop 函数: func loop(){ for i:=0;i<10;i++{ fmt

How to loop over grouped Pandas dataframe?

匿名 (未验证) 提交于 2019-12-03 01:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: DataFrame: c_os_family_ss c_os_major_is l_customer_id_i 0 Windows 7 90418 1 Windows 7 90418 2 Windows 7 90418 Code: print df for name, group in df.groupby('l_customer_id_i').agg(lambda x: ','.join(x)): print name print group I'm trying to just loop over the aggregated data, but I get the error: ValueError: too many values to unpack @EdChum, here's the expected output: c_os_family_ss \ l_customer_id_i 131572 Windows 7,Windows 7,Windows 7,Windows 7,Window... 135467 Windows 7,Windows 7,Windows 7,Windows 7,Window... c_os_major_is l_customer_id_i

Music Loop in Java

匿名 (未验证) 提交于 2019-12-03 01:54:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Good day! I am doing a game and I want it to have a background sound. I created a class for it and I call it on my main. My code is as follows: import sun.audio.*; import java.io.*; public class Sound { public void music() { AudioStream backgroundMusic; AudioData musicData; AudioPlayer musicPlayer = AudioPlayer.player; ContinuousAudioDataStream loop = null; try { backgroundMusic = new AudioStream(new FileInputStream("chickendance.wav")); musicData = backgroundMusic.getData(); loop = new ContinuousAudioDataStream(musicData); musicPlayer.start

Range-based for loop on a dynamic array?

匿名 (未验证) 提交于 2019-12-03 01:54:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: There is a range-based for loop with the syntax: for(auto& i : array) It works with constant arrays but not with pointer based dynamic ones, like int *array = new int[size]; for(auto& i : array) cout It gives errors and warnings about failure of substitution, for instance: Error] C:\Users\Siegfred\Documents\C-Free\Temp\Untitled2.cpp:16:16: error: no matching function for call to 'begin(int*&)' How do I use this new syntax with dynamic arrays? 回答1: To make use of the range-based for-loop you have to provide either begin() and end() member