Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tables, locks, threadpool
- var hlock: Lock
- var chats {.guard: hlock.}: Table[int64, int64]
- template lock(a: Lock; body: stmt): auto =
- a.acquire
- defer: a.release
- {.locks: [a].}:
- body
- proc test() =
- lock hlock:
- chats[1] = 2
- proc main() =
- lock hlock:
- chats = initTable[int64, int64]()
- spawn test()
- main()
Advertisement
Add Comment
Please, Sign In to add comment