Re: Proposal: Add a callback data parameter to GetNamedDSMSegment

Поиск
Список
Период
Сортировка
От Sami Imseih
Тема Re: Proposal: Add a callback data parameter to GetNamedDSMSegment
Дата
Msg-id CAA5RZ0u264cXvMV3ac0BqUBWLdw68EYMrUaRKs5kTpP125zSog@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Proposal: Add a callback data parameter to GetNamedDSMSegment  (Zsolt Parragi <zsolt.parragi@percona.com>)
Ответы Re: Proposal: Add a callback data parameter to GetNamedDSMSegment
Список pgsql-hackers
> struct Foo {
>     LWLock lock;
>     size_t size;
>     Bar data[];
> };
>
> * To create a few of these, I have to provide a lock name to the
> callback, that's the "reusing the same callback" part again
> * And then there's the question of initialization. Either I leave it
> to the caller after returning from GetNamedDSHash using the lock,

"caller after returning from GetNamedDSHash" <- do you mean
GetNamedDSMSegment ?

> or somehow I have to tell the initialization callback the array size -
> even if I can calculate the size based on a GUC,

```
typedef struct Bar {
int f1;
int f2;
} Bar;

typedef struct Foo {
LWLock lock;
size_t size;
Bar data[];
} Foo;

foo_state = GetNamedDSMSegment("Foo",

offsetof(Foo, data) + BAR_ARRAY_SIZE * sizeof(int),
                                                            foo_init_state,
                                                            &found);
```

wouldn't the above be sufficient to create a DSM segment containing
a flexible array?

--
Sami Imseih
Amazon Web Services (AWS)



В списке pgsql-hackers по дате отправления: