ID:               36541
 User updated by:  zabmilenko at charter dot net
 Reported By:      zabmilenko at charter dot net
 Status:           Open
 Bug Type:         Feature/Change Request
-Operating System: WinXP
+Operating System: All
 PHP Version:      5.1.2
 New Comment:

Changing the OS to ALL, because that makes more sense.


Previous Comments:
------------------------------------------------------------------------

[2006-02-27 11:00:24] zabmilenko at charter dot net

Description:
------------
Currently, the sysvsem library is used for semaphore locking.  I am
proposing to integrate this functionality directly into php using a
block-level statement:

sem (420)
{
   // Locked stuff here
}

The idea is that any code present inside the sem{} block will be
guaranteed by php to be executed alone.  420 is the lock to set or wait
for.  Execution can be halted before the end of the sem block using the
break; statement, as well as return, die, exit, or any other statement
that moves execution outside of the block.  As soon as execution
leaves, the semaphore is instantly released.

Naturally, nesting a lock is redundant but nevertheless could serve a
purpose.  If a nested lock is detected, a warning should be generated.

This functionality would be minimalistic, but powerful and elegant when
compared to the sysvsem library.  If your imagination is wandering, then
a radical idea would be setting a timeout or even a lock-count limit
using parameters separated by ; (like a for() block).

Anyways, my suggestion is a sem block.  Have a nice day.

Reproduce code:
---------------
sem (0x2243)
{
   // open a file
   // write a line
   // close the file
}

Expected result:
----------------
The first process will lock semaphore 0x2243 and attempt to write a
line to a file.  Any concurrent attempts will be delayed until the
first process reaches leaves the sem block.

Actual result:
--------------
I get a parse error because my idea is still only in my head.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36541&edit=1

Reply via email to