разработка серверов и серверных приложений лекция №2

  • Published on
    22-Jun-2015

  • View
    174

  • Download
    1

Embed Size (px)

DESCRIPTION

: 1. ( ). 2. "" . - . "" . .

Transcript

  • 1. 1. 30

2. 2. TM . 31 3. 32- - 4. 33 5. 1. 34 6. 35 , 1967 7. ? 36 , 8. 37 Vs 9. ? 38int c = 0;for(int i =0; ; ++i){c += i;}void print(int i, int *c){*c += i ;print(i+1, c);} 10. ? 39 , > 50? > 100? 11. vs 40 12. benchmarksgame.alioth.debian.org 41 13. benchmarksgame.alioth.debian.org 42 14. benchmarksgame.alioth.debian.org 43 15. benchmarksgame.alioth.debian.org 44 16. ! 45while(){// , } 17. ? 46Philipp Haler, MartinOderskyEvent-BasedProgramming WithoutInversion Control2006 Scala, C# 5 (await) 18. await C# 47static async Task SavePage(string file, string a){using (var stream = File.AppendText(file)){var html = await newWebClient().DownloadStringTaskAsync(a);await stream.WriteAsync(html);}} 19. 2. 48 20. ? 49 21. 50 vs , ( ) => 22. 51 vs => 23. Fog cutter 52Gul A. Agha,Karmani 2011 24. 531. public static void Main() {ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadProc));Thread.Sleep(1000);}static void ThreadProc(Object stateInfo) { } 25. 542. callbackspublic class MyClass {public IAsyncResult BeginSend(string host, int port, byte[] buffer,int offset, int size, AsyncCallback asyncCallback, object state) {SendAsyncResult result = new SendAsyncResult( host, port, bufferoffset, size, asyncCallback, state, this /*owner*/, "send");result.Process();return result;}public void EndSend(IAsyncResult result){AsyncResultNoResult.End(result, this, "send");}} 26. 553. awaitstatic async Task SavePage(string file, string a){using (var stream = File.AppendText(file)){var html = await newWebClient().DownloadStringTaskAsync(a);await stream.WriteAsync(html);}} 27. 564. foreach (var item in sourceCollection) {Process(item);}Parallel.ForEach(sourceCollection, item =>Process(item)); 28. 57 ?????par_foreach (var item in sourceCollection) {Process(item);} 29. 581. 2. callbacks3. await4. 5. 30. 59 31. 60http://www.regfordev.com/2010/12/thread-pool.htmlhttp://www.regfordev.com/2010/12/thread-pool.html 32. .Net 4.0 61 33. 62 34. - 63http://alice.pnzgu.ru/~dvn/complex/gl5.htm

Recommended

View more >