0

I've been trying to write a pool of database connections based on a lockable queue (well, seq in this case) called POOL. I want to have POOL as a global variable and then use initConnectionPool to instantiate it. I've tried to do so with the code below

var POOL: ConnectionPool

proc initConnectionPool*(initialPoolSize: static int) = 
  POOL = ConnectionPool(connections: @[])
  initLock(POOL.lock)

However, this throws a compiler error:

‘pthread_mutex_t {aka union <anonymous>}’ has no member named ‘abi’

I am not quite sure what this is supposed to mean or what to do about this. How can I fix this issue?

Philipp Doerner
  • 1,090
  • 7
  • 24

1 Answers1

1

Update: As of nim v. 1.6.6 this appears to no longer be an issue and work flawlessly.

For pre nim v.1.6.6:

This appears to be a known issue. Thankfully xflywind helped me out an pointed me to the right answer.

POOL = ConnectionPool(connections: @[]) within the proc is not allowed and causes the compile issue here. What you should be doing here is, instead of instantiating this object, to just assign the individual fields here as if the object already existed, since, in a way, it already does.

So this will compile:

proc initConnectionPool*(initialPoolSize: static int) = 
  POOL.connections: @[]
  initLock(POOL.lock)
Philipp Doerner
  • 1,090
  • 7
  • 24