supipd / node-shm

shared memory for NODEJS compatible with PHP shmop
63 stars 13 forks source link

support semaphores? #4

Closed jnfeinstein closed 3 years ago

jnfeinstein commented 10 years ago

It would be great if this library also supported semaphores. I'm working on an ipc library using this library and need semaphores to do blocking receives without polling. I can help do the work if you can point me in the right direction.

supipd commented 10 years ago

I don't know, if the (POSIX or System 5 IPC) semaphores are the right way for nodejs. On Windows systems it is problem. I think, that semaphores are principally some kind of polling too.

I use 2 way of synchronisation:

  1. shared memory has separated part for each process which need notice other processes. Other processes can poll information space of another processes to get info about their status
  2. one of process sharing the same memory is manager, and is socket server. Processes which want to share memory (with potencially very large data) sends only little handshake packets .

Info packets through sockets seems to be more universal way, and very native (events) for nodejs.

C source code of this SHM library was created from PHP source code ... there are semaphores too.