(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
<?xml version="1.0" encoding="utf-8"?> | |
<!-- | |
Copyright (C) 2015 The Android Open Source Project | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
// Apple Crayon Palette RGB | |
$cantaloupe: rgb(255, 206, 110); | |
$honeydew: rgb(206, 250, 110); | |
$spindrift: rgb(104, 251, 208); | |
$sky: rgb(106, 207, 255); | |
$lavender: rgb(210, 120, 255); | |
$carnation: rgb(255, 127, 211); | |
$licorice: rgb(0, 0, 0); | |
$snow: rgb(255, 255, 255); |
本文基本上这为两篇文章的翻译和整合 -- Scalable networking And Why are event-driven server so great
传统服务器模型如Apache为每一个请求生成一个子进程。当用户连接到服务器的一个子进程就产生,并处理连接。每个连接获得一个单独的线程和子进程。当用户请求数据返回时,子进程开始等待数据库操作返回。如果此时另一个用户也请求返回数据,这时就产生了阻塞。
这种模式在非常小的工作负荷是表现良好,当请求的数量变得太大是服务器会压力过于巨大。 当Apache达到进程的最大数量,所有进程都变得缓慢。每个请求都有自己的线程,如果服务代码使用PHP编写时,每个进程所需要的内存量是相当大的[1]。
// AndroidManifest.xml must have the following permission: | |
// <uses-permission android:name="android.permission.GET_TASKS"/> | |
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); |