Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ʹÓÃlinux¹²ÏíÄÚ´æµÄʵÏÖµÄphpÄÚ´æ¶ÓÁÐ

<?php
/**
* ʹÓù²ÏíÄÚ´æµÄPHPÑ­»·ÄÚ´æ¶ÓÁÐʵÏÖ
* Ö§³Ö¶à½ø³Ì, Ö§³Ö¸÷ÖÖÊý¾ÝÀàÐ͵Ĵ洢
* ×¢: Íê³ÉÈë¶Ó»ò³ö¶Ó²Ù×÷,¾¡¿ìʹÓÃunset(), ÒÔÊÍ·ÅÁÙ½çÇø
*
* @author wangbinandi@gmail.com
* @created 2009-12-23
*/
class SHMQueue
{
private $maxQSize = 0; // ¶ÓÁÐ×î´ó³¤¶È

private $front = 0; // ¶ÓÍ·Ö¸Õë
private $rear = 0; // ¶ÓβָÕë

private $blockSize = 256; // ¿éµÄ´óС(byte)
private $memSize = 25600; // ×î´ó¹²ÏíÄÚ´æ(byte)
private $shmId = 0;

private $filePtr = './shmq.ptr';

private $semId = 0;
public function __construct()
{
$shmkey = ftok(__FILE__, 't');

$this->shmId = shmop_open($shmkey, "c", 0644, $this->memSize );
$this->maxQSize = $this->memSize / $this->blockSize;

// Éê請Ò»¸öÐźÅÁ¿
$this->semId = sem_get($shmkey, 1);
sem_acquire($this->semId); // ÉêÇë½øÈëÁÙ½çÇø

$this->init();
}

private function init()
{
if ( file_exists($this->filePtr) ){
$contents = file_get_contents($this->filePtr);
$data = explode( '|', $contents );
if ( isset($data[0]) && isset($data[1])){
$this->front = (int)$data[0];
$this->rear = (int)$data[1];
}
}
}

public function getLength()
{
return (($this->rear - $this->front + $this->memSize) % ($this->memSize) )/$this->blockSize;
}

public function enQueue( $value )
{
if ( $this->ptrInc($this->rear) == $this->front ){ // ¶ÓÂú
return false;
}

$data = $this->encode($value);
shmop_write($this->shmId, $data, $this->rear );
$this->rear = $this->ptrInc($this->rear);
return true;
}

public function deQueue()
{
if ( $this->front == $this->rear ){ // ¶Ó¿Õ
return false;
}
$value = shmop_read($this->shmId, $this->front, $this->blockSize-1);
$this->front = $this->ptrInc($this->front);
return $this->decode($value);
}

private function pt


Ïà¹ØÎĵµ£º

LinuxÉ豸ģÐÍÖ®input×ÓϵͳÏê½â

Ò»£ºÇ°ÑÔ
×î½üÔÚÑо¿androidµÄsensor driver£¬Ö÷ÒªÊÇE-compass£¬ÆäÖÐÓõ½ÁËLinux input×Óϵͳ.ÔÚÍøÉÏÒ²¿´Á˺ܶàÕâ·½ÃæµÄ×ÊÁÏ£¬¸Ð¾õ»¹ÊÇÕâÆª·ÖÎöµÄ±È½ÏϸÖÂ͸³¹£¬Òò´Ë×ªÔØÒ»ÏÂÒÔ±ã×Ô¼ºÑ§Ï°£¬Í¬Ê±ºÍ´ó¼Ò·ÖÏí£¡
£¨ÕâÆª²©¿ÍÖ÷ÒªÊÇÒÔ¼üÅÌÇý¶¯ÎªÀýµÄ£¬²»¹ý½²½âµÄÊÇLinux Input Subsystem£¬¿ÉÒÔ×ÐϸµÄÑо¿Ò»Ï£¡£©
¼üÅÌÇý¶¯½«¼ì ......

ѧϰlinuxǶÈëʽÓйØÍøÕ¾ºÍblog(²»¶¨ÆÚ¸üУ©

http://www.linuxgraphics.cn/android/index.html
http://blog.chinaunix.net/u2/85805/
http://blog.csdn.net/stevenliyong/category/578556.aspx
http://blog.csdn.net/cuijpus/archive/2008/06/15/2549803.aspx
http://dbus.freedesktop.org/doc/dbus-tutorial.html#glib-client
http://www.ibm.com/developerworks ......

PHP²»ÊʺÏMVC¿ò¼Ü

×î½ü¹¤×÷·¶³ëÓÉÔ­À´µÄ.netÇл»µ½ÁËphp£¬×ÛºÏÕâ¶Îʱ¼äµÄÈÏÖª£¬¾õµÃÔÚphpÕâ¸öÌåϵÖÐMVCģʽδ±ØÊÇÒ»¸öºÃ¶«Î÷¡£
´ÓijÖÖÀíÂÛÉÏÀ´Ëµ,MVCȷʵ¿ÉÒÔÈÃϵͳ¸üÇåÎúºÍ¸üÃ÷ÁË¡£
µ«ÊÇÒ»¸öºÜÖØÒªµÄÒ»µãÒ²´æÔÚÁË£¬MVCÈÃÒ³Ãæ¸ü¶àÁËÆðÀ´£¡£¡£¡ÕâµãºÜÖØÒª
PHPÔÚûÓÐÒ»¸ö±È½ÏºÃµÄIDEµÄÖ§³ÖÏ£¬Ò³ÃæÌø×ªºÍÇл»ÊµÔÚÊǷdz£²»·½±ã¡£
ûÓÐÒ»¸öºÃ ......

PHP±à³Ìˮƽ·Ö¼¶(ת)

˵¾äʵ»°,дÕâ¸öÕæ¹»ÎÞÁĵÄ.±¾À´¿´ÁËijλ´óϺµÄÀàËÆÎÄÕÂ,¸¹·ÌÁ˼¸¾äÒ²¾ÍËãÁË.µ«ÊÇ×òÌìÍíÉÏÓиö¿Í»§ÄÃ×ÅÕâÆªÎÄÕÂÎÊÎÒ: ÄãѾµÄ×Ô¼º×ö
Íâ°ü,ÄãË㼸¶ÎPHPer?Ëì¸Ð¾õÄÇÆªÎÄÕ¶ÔijЩ°ëͨ²»Í¨Ö®È˵ÄÎóµ¼Ö®Éî.ÎÞ·¨,Ö»ÓÐд´ËÎÄÕ±íÃ÷ÎÒ¶ÔPHPerµÄË®Æ½Çø·ÖµÄÁ¢³¡.
¹ØÓÚ¾ßÌåÊÕÈëˮƽ,×ܵÄÀ´ËµÒòΪÕ⼸ÄêPHPÅàѵ°àµÄ¼Ó¶à,´óÁ¿PHPÐÂÊÖ¿ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ