class GrBatch_Globals {
public:
    static GrMemoryPool* GetTLS() {
        return (GrMemoryPool*)SkTLS::Get(CreateTLS, DeleteTLS);
    }

private:
    static void* CreateTLS() {
        return SkNEW_ARGS(GrMemoryPool, (16384, 16384));
    }

    static void DeleteTLS(void* pool) {
        SkDELETE(reinterpret_cast<GrMemoryPool*>(pool));
    }
};

int32_t GrBatch::gCurrBatchClassID =
        GrBatch::kIllegalBatchClassID;

void* GrBatch::operator new(size_t size) {
    return GrBatch_Globals::GetTLS()->allocate(size);
}

void GrBatch::operator delete(void* target) {
    GrBatch_Globals::GetTLS()->release(target);
}
