@@ -51,25 +51,27 @@ class TestWorkerWithUserDefRecv : public AsyncWorker {
5151};
5252
5353// Using default std::allocator impl, but assuming user can define their own
54- // alloc/dealloc methods
54+ // allocate/deallocate methods
5555class CustomAllocWorker : public AsyncWorker {
56+ using Allocator = std::allocator<CustomAllocWorker>;
57+
5658 public:
5759 CustomAllocWorker (Function& cb) : AsyncWorker(cb){};
5860 static void DoWork (const CallbackInfo& info) {
5961 Function cb = info[0 ].As <Function>();
60- std::allocator<CustomAllocWorker> create_alloc ;
61- CustomAllocWorker* newWorker = create_alloc .allocate (1 );
62- create_alloc. construct (newWorker, cb);
62+ Allocator allocator ;
63+ CustomAllocWorker* newWorker = allocator .allocate (1 );
64+ std::allocator_traits<Allocator>:: construct (allocator, newWorker, cb);
6365 newWorker->Queue ();
6466 }
6567
6668 protected:
6769 void Execute () override {}
6870 void Destroy () override {
6971 assert (this ->_secretVal == 24 );
70- std::allocator<CustomAllocWorker> deallocer ;
71- deallocer. destroy (this );
72- deallocer .deallocate (this , 1 );
72+ Allocator allocator ;
73+ std::allocator_traits<Allocator>:: destroy (allocator, this );
74+ allocator .deallocate (this , 1 );
7375 }
7476
7577 private:
@@ -108,7 +110,7 @@ class TestWorker : public AsyncWorker {
108110 : AsyncWorker(cb, resource_name, resource) {}
109111 TestWorker (Function cb, const char * resource_name)
110112 : AsyncWorker(cb, resource_name) {}
111- bool _succeed;
113+ bool _succeed{} ;
112114};
113115
114116class TestWorkerWithResult : public AsyncWorker {
@@ -143,7 +145,7 @@ class TestWorkerWithResult : public AsyncWorker {
143145 const char * resource_name,
144146 const Object& resource)
145147 : AsyncWorker(cb, resource_name, resource) {}
146- bool _succeed;
148+ bool _succeed{} ;
147149};
148150
149151class TestWorkerNoCallback : public AsyncWorker {
@@ -194,7 +196,7 @@ class TestWorkerNoCallback : public AsyncWorker {
194196 : AsyncWorker(env, resource_name, resource),
195197 _deferred(Napi::Promise::Deferred::New(env)) {}
196198 Promise::Deferred _deferred;
197- bool _succeed;
199+ bool _succeed{} ;
198200};
199201
200202class EchoWorker : public AsyncWorker {
0 commit comments