[NamedPipe] Support an optional GMainContext.