Subscribe to all objects in a directory

Updated: May 06, 2022

PPS uses directories as a natural grouping mechanism to simplify and make more efficient the task of subscribing to multiple objects. You can open multiple objects by calling open() and then poll() on their file descriptors. More easily, you can open the special .all object, which merges all objects in its directory.

For example, assume the following object file structure under /pps:

rear/left/PlayCurrent
rear/left/Time
rear/left/PlayError

If you open rear/left/.all you will receive a notification when any object in the rear/left directory changes. A read in full mode will return at most one object per read.

read()
@Time
  position::18
  duration::300

read()
@PlayCurrent
  artist::The Beatles
  genre::Pop
  ... the full set of attributes for the object

If you open a .all object in delta mode, however, you will receive a queue of every attribute that changes in any object in the directory. In this case, a single read() call may include multiple objects.

read()
@Time
  position::18
@Time
  position::19
@PlayCurrent
  artist::The Beatles
  genre::Pop